mini-css-extract-plugin 提取的css不能直接link引入

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
        }
      },
    }
 
阅读 5.8k
1 个回答

new MiniCssExtractPlugin那里配置publicPath

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题