nuxt.js框架默认使用过了一套配置,但是看了编译出来的源码后发现css文件全部在源码里,感觉不是很利于收缩引擎的SEO,所以自定义了打包配置,代码如下:
optimization: { runtimeChunk: { name: 'manifest' }, splitChunks: { chunks: 'all', cacheGroups: { libs: { name: 'chunk-libs', chunks: 'initial', priority: -10, reuseExistingChunk: false, test: /node_modules\/(.*)\.js/ }, styles: { name: 'chunk-styles', test: /\.(scss|css)$/, chunks: 'all', minChunks: 1, reuseExistingChunk: true, enforce: true } } } }, extractCSS: true, /** 将css单独打包成一个文件,默认的是全部加载到有事业 **/