K
K
kugimiya2018-07-06 13:20:31
JavaScript
kugimiya, 2018-07-06 13:20:31

What plugin does Webpack need to build multiple bundles?

Ohio.
I want to improve the codebase of my pet project. There is now noodle code, and I decided to break it into modules. I've been poking around with Webpack for a while and have some idea about it. But now I’m in a stupor and I can’t find information on the most common case.
Bottom line: I have some core.js , and for several pages there is pageA.js and pageB.js . It's important for me to share it this way. Everything seems to be fine, but on a regular Webpack config, pageA.js is assembled with all the internals from core.js
To make it a little clearer, here:

# core/lib/func.js
export function sayHello () { /* ... */ }

# pageA/index.js
import { sayHello } from './../core/lib/func'
sayHello ()

And it turns out that sayHello is located both in core.js and in pageA.js (and you shouldn’t need to in
pageA.js ) bundle? (well, something like with externals: { jquery: 'jQuery' } )
(I just want core.js to be cached so that the code that is definitely needed here and there does not compete over the network every time)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question