背景:升级到 webpack4.0 后,配置修改,主要是 babel-loader\css-loader\post-loader\less-loader 修改:
{
test:/\.(js|mjs|jsx|ts|tsx)$/,
include:paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
plugins: [['import', {
libraryName:'antd',
style:true
}]],
// cacheDirectory: true,
// // cacheCompression: true,
// compact: true,
}
},
{
test:/\.css$/,
use: ['style-loader', 'css-loader',],
},
{
test:/\.less$/,
use: [
{loader:"style-loader" },
{loader:"css-loader" },
{
loader:"postcss-loader",//自动加前缀
options: {
plugins:[
require('autoprefixer')({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox:'no-2009',
})
]
}
},
{loader:"less-loader",
options: {
javascriptEnabled: true,
modifyVars:themeConfig,
}
}
]
},