Nuxt.js: How to package the CSS file into a separate file

Created on 30 Aug 2017  路  16Comments  路  Source: nuxt/nuxt.js

image
image
the above configuration does not take effect

This bug report is available on Nuxt.js community (#c1366)
bug-confirmed question

All 16 comments

How to make the embedded style automatically extract to the css file? In fact this is mainly on the seo not very friendly? Some search engines are particularly fond of inline styles and base64 images

@HadiChen Hello!

It looks like your example is from a pages/web.vue component. Can you share the contents of that components <style> tag?

@jsonberry
image

Asked, I also encountered this problem
/ping @alexchopin

having the same issue.

also, it would be cool if the css property in the config file would extract all the css in one big file that could be cached, so the browser don't need to load the whole css every time the page gets loaded.

ps: keep up the good work. love your project so far.

@Atinux It seems that this problem has not been solved and we hope that it will be resolved

Any solution for this problem?

+1 . the nuxt still embed all css into every html files, that make html file size very large...
any solution to extract the css in a common css file and include it in html file instead of embeding all the complied css inline in html file?

guys you just add extractCSS: true to your nuxt.config.js to see this works .

after that npm run build then npm run start.

add

extractCSS: {
      allChunks: true
    }

to your nuxt.config.js @TonyLuo

@HadiChen it doesn't work for me....

Try

build: {
  extractCSS: {
    allChunks: true
  }
}

instead, this is what worked for me.

which command do you run? I run " npm run generate" to generate static html , the generated html files contain full set of embed css...

I use npm run generate too, what I posted above is what splited the CSS in its own file.

The whole relevant content of my nuxt.config.js:

module.exports = {
  ...,
  css: [
    '~/assets/styles/main.scss',
  ],
  build: {
    extractCSS: {
      allChunks: true
    },
    ...
  },
  ...
}

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

uptownhr picture uptownhr  路  3Comments

mikekidder picture mikekidder  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments

bimohxh picture bimohxh  路  3Comments