webpack4 多页面项目打包后,公共代码没有被页面引用

部分配置:

optimization: {
  splitChunks: {
    cacheGroups: {
      vendor: {
        test: /\.js$/,
        chunks: "all", 
        name: "vendor",
        minChunks: 1
      }
    }
  }
}

vendor.js文件已经生成,但没有被页面引用

阅读 1.6k
1 个回答
// Generates an `index.html` file with the <script> injected.
        new HtmlWebpackPlugin(
            {
                inject   : true,
                template : paths.appHtml,
                minify   : {
                    removeComments                : true,
                    collapseWhitespace            : false,
                    removeRedundantAttributes     : true,
                    useShortDoctype               : true,
                    removeEmptyAttributes         : true,
                    removeStyleLinkTypeAttributes : true,
                    keepClosingSlash              : true,
                    minifyJS                      : true,
                    minifyCSS                     : true,
                    minifyURLs                    : true
                }
            }
        ),

inject配置了么

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