2

I am creating a 1 file component in Vue within my Laravel (test) project. But i use less for the css so the css part is in a different file. Now I want to include this file but without any luck. I try to look on stack overflow but am not sure if am searching incorrect or that I am doing something that I am not supposed to do.

Sitemap

What i try to do is

<style src="css/sidebar.css"></style>

I use the same logic for the image

<img class="flex-item" src="img/Home-icon.png">

But when i do "npm run dev" I get this error

So I thought this maybe wil work:

<style src="../public/css/sidebar.css"></style>

but then i get the same error but of cours with different path.

So I am a bit lost right now. Anyone that can help me with this?

1 Answer 1

4

You need to put the relative path from your component file in the project. I use sass, so I use @import. Not sure how to import in less. But I show you how I do it in sass.

// my-component.vue
<template></template>
<script></script>
<style lang="scss" scoped>
    @import "../../relative/path/to/file.scss";
</style>    

My example is with Sass. I'm sure you can easily translate it to less.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.