//下面的是对create-react-app配置中对css的配置constcssFilename='static/css/[name].[contenthash:8].css';constextractTextPluginOptions=shouldUseRelativeAssetPaths?{publicPath:Array(cssFilename.split('/').length).join('../')}:{};{test:/\.css$/,loader:ExtractTextPlugin.extract(Object.assign({fallback:require.resolve('style-loader'),use:[{loader:require.resolve('css-loader'),options:{importLoaders:1,minimize:true,sourceMap:true,},},{loader:require.resolve('postcss-loader'),options:{ident:'postcss',//https://webpack.js.org/guides/migrating/#complex-optionsplugins:()=>[require('postcss-flexbugs-fixes'),autoprefixer({browsers:['>1%','last4versions','FirefoxESR','notie
2 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
开头引入constwebpack=require("webpack");constExtractTextPlugin=require("extract-text-webpack-plugin");//...然后webpack({entry:{//...},output:{//...},module:{rules:[{test:/\.css$/,include:[path.resolve(__dirname,"./css")],use:ExtractTextPlugin.extract({fallback:"style-loader",use:['css-loader?minimize=true']})}//...]},plugins:[//...newExtractTextPlugin('min.css')//CSS就在该文件下]});
添加回答
举报
0/150
提交
取消