Brunch: separating vendor and app javascript

前端 未结 1 754
梦毁少年i
梦毁少年i 2021-01-13 00:45

I have made two bundles of javascript from our project- vendor and app. I do this in the manner suggested by the documentation, as seen in this snippet from my brunch-config

1条回答
  •  野的像风
    2021-01-13 01:18

    The problem is caused by the mixture of joinTo and entryPoints. I assume that with your config, you first split your code in app.js and vendor.js but then the app.js gets overridden by the output of the entryPoints.

    In order to solve it, you have to choose one of the options:

    Option 1

    Remove the entryPoints declaration. This will just split your code along the provided RegEx.

    Option 2

    Remove the joinTo declaration and change the entryPoints to:

        entryPoints: {
          'source/scripts/app.jsx': {
            'js/vendor.js': /^(?!source\/)/,
            'js/app.js': /^source\//
          },
        }
    

    Conclusion

    In this very case, the output of both options is the same. But with entryPoints the code get's analyzed and only needed modules get bundled. Because there aren't any unnecessary modules, the size is the same. See this issue for more information.

    0 讨论(0)
提交回复
热议问题