在webpack v4.x中
// webpack v4.x code
module: {
rules: [
{
test: require.resolve('./src/index.js'),
use: 'imports-loader?this=>window',
}
]
}
可是在chainWebpack编写不生效
// use chainWebpack not working
chainWebpack: config => {
config.module
.rule('.js')
.test(require.resolve('./src/libs/test.js'))
.use('imports-loader')
.loader('imports-loader?this=>window')
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…