亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

webpack 分離css問題

webpack 分離css問題

呼啦一陣風 2019-05-24 18:32:46
//下面的是對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就在該文件下
]
});
                            
查看完整回答
反對 回復 2019-05-24
  • 2 回答
  • 0 關注
  • 545 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號