Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack code split #190

Open
teazean opened this issue Nov 23, 2017 · 0 comments
Open

webpack code split #190

teazean opened this issue Nov 23, 2017 · 0 comments

Comments

@teazean
Copy link
Owner

teazean commented Nov 23, 2017

见文档: https://webpack.js.org/guides/code-splitting/

主要实现由三种:

  1. 人工分割
  2. CommonChunkPlugin
  3. import()

重点讲一下第三种,动态import(),import()是ecma提案中的一个,返回一个promise。在webpack里面可以这么用,结合注释webpackChunkName来生成动态的chunk:

import(/* webpackChunkName: "lodash" */ 'lodash').then(_ => {
    // something
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant