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

How to extract common chunks in multiple resource files #249

Open
yvanwangl opened this issue Sep 18, 2019 · 2 comments
Open

How to extract common chunks in multiple resource files #249

yvanwangl opened this issue Sep 18, 2019 · 2 comments

Comments

@yvanwangl
Copy link

yvanwangl commented Sep 18, 2019

As the resource files are build by independent webpack compilers. So how can we extract common chunks in multiple resource files?

@mathieudutour
Copy link
Member

That's a good question, and I don't know the answer hahaha

Any reason you want to do that? Reduce the plugin size?

@yvanwangl
Copy link
Author

yvanwangl commented Sep 23, 2019

@mathieudutour Yes, when I build my plugin, I found that third-party ui libraries are packaged in every webView js resources, so the plugin size is so huge. Now the plugin size is larger than 33M :(.

When I read the builder code, I found the resources files are mapped to be build by webpack:

for (const entry of entries) {
    const compiler = webpack(await webpackConfig(entry))
    if (watch) {
      // https://github.com/webpack/webpack.js.org/issues/125
      // watchOptions need to be manually passed to the watch() method.
      compilers.push(
        compiler.watch(
          compiler.options.watchOptions,
          buildCallback(entry.script, watch)
        )
      )
    } else {
      compiler.run(buildCallback(entry.script))
    }
  }

source code
If we pass the entries to webpack directly, we can use only one webpack compiler to build mutil-entries, in this way we can extract common chunks in multiple resource files.
How do you think about it?
I look forward to hearing from you.

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

2 participants