1

I am working on a Vue JS app (version 2.5.17) using the webpack-simple project time, and I am trying to load a static css file in my main App component.

I have the file in:

src/static/reset.css

Then in my main app component template:

<link rel="stylesheet" type="text/css" href="/static/reset.css">

I am serving using npm run dev

However the CSS file returns a 404 error, and I can confirm by trying to access: http://localhost:8080/static/reset.css

My directory structure:

C:.
|   .babelrc
|   index.html
|   output.doc
|   package-lock.json
|   package.json
|   README.md
|   webpack.config.js
|                
\---src
    |   App.vue
    |   main.js
    |   routes.js
    |   
    +---assets
    |   |   logo.png
    |   |   
    |   \---css
    +---components
    |   |   Home.vue
    +---static
    |       reset.css
    |       
    \---store
        |   store.js
        |   
        \---modules
                recipe.js
2
  • can you share you directory structure? Commented Nov 21, 2018 at 15:37
  • Edited my post to include directory structure Commented Nov 21, 2018 at 16:13

1 Answer 1

1

You can put your css file in the assets/css folder and then import it in main.js by doing import '@/assets/css/reset.css'. Check out How the hell can i include a css file on GitHub for many other varieties.

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.