MiniCssExtractPlugin 提取css为什么会生成一个同名的js文件,引入了这个js才能把提取出的css link引入,是配置的有问题还是本来就这样。
new HtmlWebpackPlugin({
title: "GoldEgg",
template: "./src/page/index/index.html",
chunks: ["commons", "index", "styles"],
filename: "index.html",
favicon: ''
})
plugins: [
new MiniCssExtractPlugin({
filename: "css/[name].[hash:6].css",
// chunkFilename: "css/[name].[hash:6].css",
}),
splitChunks: {
chunks: "all",
minSize: 1,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
name: true,
cacheGroups: {
commons: {
name: "commons",
chunks: "all",
minChunks: 2,
filename: "js/[name].[hash:6].js"
},
styles: {
name: 'styles',
test: /\.(css|scss)$/,
chunks: 'all',
enforce: true
}
},
}
new MiniCssExtractPlugin那里配置publicPath