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

nuxt 重复打包所有子组件的问题

  •  
  •   e8c47a0d · Jul 12, 2018 · 2766 views
    This topic created in 2846 days ago, the information mentioned may be changed or developed.
    比如我在 components 做了一个比较大的组件,网站每个页面使用这个组件,那么打包以后,每个页面都有组件的所有代码。非常浪费,如何解决呢?
    7 replies    2018-07-12 17:20:50 +08:00
    heww
        1
    heww  
       Jul 12, 2018   ❤️ 1
    升级到 nuxt-edge 或者等 nuxt 2 的发布,据说 webpack 4 可能有解。
    heww
        2
    heww  
       Jul 12, 2018   ❤️ 1
    如果是没有页面都用的还可以添加到 vendor 中去,这样的话会打包到 vendor.js 文件里
    heww
        3
    heww  
       Jul 12, 2018   ❤️ 1
    没有 => 每个
    e8c47a0d
        4
    e8c47a0d  
    OP
       Jul 12, 2018
    @heww 我竟然不知道有 nuxt-edge 这个包!感谢大哥,我去看看!!还有用 vendor 打包 axios 确实好用!
    heww
        5
    heww  
       Jul 12, 2018
    @e8c47a0d #4 nuxt-edge 不是单独的包,是 nuxt 发布 2.0 版本前的测试版本。
    e8c47a0d
        6
    e8c47a0d  
    OP
       Jul 12, 2018
    我现在的解决方法暂时是:在 nuxt.config.js 里面,加上 render: { resourceHints: false } 属性,减少那些 prefetch,暂时可以眼不见心不乱。
    e8c47a0d
        7
    e8c47a0d  
    OP
       Jul 12, 2018
    我以为 nuxt 不更新了~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4218 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 00:55 · PVG 08:55 · LAX 17:55 · JFK 20:55
    ♥ Do have faith in what you're doing.