Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuxt.js add css file

Tags:

vue.js

nuxt.js

I've created nuxt project vue init nuxt/starter <project-name>

In my nuxt.config.js I added this:

css: [
        { src: '~assets/css/style.css', lang: 'css' }
    ]

and in my assets/css folder I have style.css with

body {
    background: black!important;
}

But nothing happens with no errors on console. what to I do?

like image 612
user2950593 Avatar asked Mar 08 '23 15:03

user2950593


1 Answers

you must add to nuxt.config.js

build: {
        extractCSS: true
    }

For example,

css: [
        { src: '~assets/css/style.css', lang: 'css' }
    ],
build: {
            extractCSS: true
        }

And use nuxt v0.10.6

like image 184
Jussia Avatar answered Mar 19 '23 09:03

Jussia