webapck将css 打包后单独提取到一个css文件中
生活随笔
收集整理的這篇文章主要介紹了
webapck将css 打包后单独提取到一个css文件中
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
webpack4 提倡, 一旦用了這個, 不能使用style-loader 以及css module
安裝
npm install --save-dev mini-css-extract-plugin rules rules: [{test: /\.css$/,use: [ {loader: MiniCssExtractPlugin.loader,options: {// you can specify a publicPath here// by default it use publicPath in webpackOptions.outputpublicPath: '../'}}, "css-loader"]}] plugins new MiniCssExtractPlugin({// Options similar to the same options in webpackOptions.output// both options are optionalfilename: _modeflag ? "styles/[name].[hash:5].css" : "styles/[name].css",chunkFilename: _modeflag ? "styles/[id].[hash:5].css" : "styles/[id].css"}),總結
以上是生活随笔為你收集整理的webapck将css 打包后单独提取到一个css文件中的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不使用先验知识与复杂训练策略,从头训练二
- 下一篇: NOIP 2012 同余方程