vue-cli2 npm run build --report 有两个 js 重复压缩了多次? 为何? 怎么处理?

2019-08-26 17:37:24 +08:00
 SkYouth

求大佬帮忙。

图片见: https://sm.ms/image/YgAs86KRlboviXp 左侧

webpack 默认的配置 没动过

    new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            minChunks (module) {
                // any required modules inside node_modules are extracted to vendor
                // 将所有依赖于 node_modules 下面文件打包到 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
        // 把 webpack 的 runtime 代码和 module manifest 代码提取到 manifest 文件中,防止修改了代码但是没有修改第三方库文件导致第三方库文件也打包的问题
        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
        }),
3962 次点击
所在节点    Vue.js
2 条回复
arrow8899
2019-08-26 17:53:14 +08:00
确定是同一个文件吗
SkYouth
2019-08-26 18:54:31 +08:00
@arrow8899 同一个文件。 排查了一下午,现在感觉是
```
const XXXXX= () => import('@/XXXXX')
```
引入组件的方式引起的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/595287

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX