V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
SkYouth
V2EX  ›  Vue.js

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

  •  
  •   SkYouth · Aug 26, 2019 · 4548 views
    This topic created in 2440 days ago, the information mentioned may be changed or developed.

    求大佬帮忙。

    图片见: 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 replies    2019-08-26 18:54:31 +08:00
    arrow8899
        1
    arrow8899  
       Aug 26, 2019
    确定是同一个文件吗
    SkYouth
        2
    SkYouth  
    OP
       Aug 26, 2019
    @arrow8899 同一个文件。 排查了一下午,现在感觉是
    ```
    const XXXXX= () => import('@/XXXXX')
    ```
    引入组件的方式引起的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2553 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 06:57 · PVG 14:57 · LAX 23:57 · JFK 02:57
    ♥ Do have faith in what you're doing.