V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
SkYouth
V2EX  ›  Vue.js

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

  •  
  •   SkYouth · 2019-08-26 17:37:24 +08:00 · 3943 次点击
    这是一个创建于 1676 天前的主题,其中的信息可能已经有所发展或是发生改变。

    求大佬帮忙。

    图片见: 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
            }),
    
    2 条回复    2019-08-26 18:54:31 +08:00
    arrow8899
        1
    arrow8899  
       2019-08-26 17:53:14 +08:00
    确定是同一个文件吗
    SkYouth
        2
    SkYouth  
    OP
       2019-08-26 18:54:31 +08:00
    @arrow8899 同一个文件。 排查了一下午,现在感觉是
    ```
    const XXXXX= () => import('@/XXXXX')
    ```
    引入组件的方式引起的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1242 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 23:25 · PVG 07:25 · LAX 16:25 · JFK 19:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.