Nuxt.js: css extracted to the css file

Created on 20 Dec 2017  ·  16Comments  ·  Source: nuxt/nuxt.js

I look forward to css extracted to the css file, because of such a use, not recognized in China Baidu seo, or look forward to a method to achieve css extraction, do not need to be embedded in the page css

image
image
image

This question is available on Nuxt.js community (#c2102)

Most helpful comment

I opened a pr to fix the HMR issue in ExtractTextPlugin and enable the plugin.

All 16 comments

There is no solution here
image
/ping @jericopulvera @syropian @Atinux

Why is this issues closed without a solution?
/ping @Atinux

My project is also plagued by this problem, looking forward to get resolved as soon as possible

Ping @clarkdo

ExtractTextPlugin has been configurable in nuxt.config.js which will be included in next release.

module.exports = {
  build: {
    extractCSS: {
      allChunks: true
    }
  }
}

For a quick fix, you may config ExtractTextPlugin through build.extend

module.exports = {
  build: {
    extractCSS: true,
    extend(config, options) {
      const extract = config.plugins.find(plugin => plugin.renderExtractedChunk)
      extract.options.allChunks = true
    }
  }
}

image
Nuxt I use is indeed the latest, is a direct github installation, but still can not use the following configuration ah! !

module.exports = {
  build: {
    extractCSS: {
      allChunks: true
    }
  }
}

Ping @clarkdo

image
image
The problem is not solved
Ping @clarkdo

Did you run the service by dev or build and start ?

I have tried by yarn build, the bundle files seemed work.

npm run dev

For dev, I think because ExtractTextPlugin doesn't work well with HMR, so @pi0 has commented it.

Well, understood, thank you very much, only build can be fine

I opened a pr to fix the HMR issue in ExtractTextPlugin and enable the plugin.

perfect very helpful to me!

then how to fix this?

@willin this was fixed, and you just just adding extractCSS: true to your nuxt.config.js

and run npm build then npm run start. after that open the page_source to see that.

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

o-alexandrov picture o-alexandrov  ·  3Comments

bimohxh picture bimohxh  ·  3Comments

jaredreich picture jaredreich  ·  3Comments

bimohxh picture bimohxh  ·  3Comments

vadimsg picture vadimsg  ·  3Comments