vue-cli 的app manifest vendor 这三个js 可以合并到一起么?

new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks (module) {
        // any required modules inside node_modules are extracted to vendor
        return (
          module.resource &&
          /\.js$/.test(module.resource) &&
          module.resource.indexOf(
            path.join(__dirname, '../node_modules')
          ) === 0
        )
      }
    }),
    // extract webpack runtime and module manifest to its own file in order to
    // prevent vendor hash from being updated whenever app bundle is updated
    new webpack.optimize.CommonsChunkPlugin({
      name: 'manifest',
      minChunks: Infinity
    }),
    // This instance extracts shared chunks from code splitted chunks and bundles them
    // in a separate chunk, similar to the vendor chunk
    // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
    new webpack.optimize.CommonsChunkPlugin({
      name: 'app',
      async: 'vendor-async',
      children: true,
      minChunks: 3
    }),

这里好像是生成这3个文件的地方,我是否可以修改这里 然后让这三个文件打包在一起,我想让h5 少一点请求,因为这几个文件都不是很大

阅读 5.3k
1 个回答

不使用CommonsChunkPlugin可以打包在一起,但是不建议这么做,这三个js分别对应着第三方依赖缓存包,代码分割,使用这个插件能提高你项目的加载速度.虽然你打包在一次请求次数少了,但是请求也相对就大了,首屏渲染也慢!

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