4

I try to put css files on assets assest/css/style.css and call it to my nuxt.config.js but it is not working i need to use global css not scoped css

can someone help me?

when i add css in the nuxt.config.js

   /*
  ** Global CSS
  */
  css: [
      '~assets/css/style.css'
  ],

its not working ? nuxt version 2

3
  • Hi, welcome to stack overflow. Please refer the How to Ask link for more details on how to ask a question and update your question accordingly. Commented Nov 10, 2018 at 7:17
  • it should work, provide full not working code otherwise Commented Nov 10, 2018 at 10:24
  • Have you tried turning it off and on again? Seriously, changes in nuxt.config.js aren't applied unless you restart nuxt. Make some ridiculously obvious change in your CSS that you simply can't miss, like setting the background of the body to #0000ff !important or something, just so you can be certain it's not just some other stylesheet you're loading that overrides your own CSS. Commented Nov 14, 2018 at 1:36

2 Answers 2

7

I came across the same issue and solved it putting the file path to my css inside the css options and inside modules. Example code below. Hope it helps. I'm also using nuxt-sass-resources-loader to load my sass files globally.

css: [
  '@/assets/css/reset.css',
  '@/assets/css/main.scss',
],
modules: [
 [
  'nuxt-sass-resources-loader',
  ['./assets/css/main.scss'],
  ['./assets/css/reset.css']
 ]
],
Sign up to request clarification or add additional context in comments.

Comments

2

Simply restart the server. Adding the code to the module should not be necessary.

1 Comment

After modifying the nuxt.config, a server restart (Ctrl + C, npm run dev) is always necessary.

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.