-
Notifications
You must be signed in to change notification settings - Fork 20
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
Missing documentation for splitting different entry points #180
Comments
The As for
the stats object has different shapes/fields across webpack versions IIRC, so it's a bigger lift to create a feature to do this in the In terms of getting you going -- how to do this for a modern webpack would be in the example code I provided there. An updated example (with some new /**
* Multiple entry points with per-entry-point stats output example.
*/
const { StatsWriterPlugin } = require("webpack-stats-plugin");
module.exports = {
// ... all the other webpack options ...
entry: {
main: "../src/main.js",
two: "../src/main.js",
three: "../src/main.js"
},
plugins: [
new StatsWriterPlugin({
// The plugin will not emit a stats asset. We'll individually add those in `transform()`
emit: false,
fields: ["assets", "modules"],
transform({ assets, modules }, { compiler }) {
Object.keys(assets).forEach((assetIdx) => {
// Reconstitute assets, modules filtered by this specific asset.
const asset = assets[assetIdx];
const assetChunks = new Set(asset.chunks);
const assetStr = JSON.stringify({
assets: [asset],
modules: modules.filter((mod) => mod.chunks.some((c) => assetChunks.has(c)))
});
// Convert `[hash].[name].js` to `[name]` for later use.
// This replace depends on how you are specifying asset outputs.
const assetName = asset.name.replace(/.*?\.(.*?)\.js/, "$1");
// Add per-asset output.
compiler.assets[`stats-multi-${assetName}.json`] = {
source() { return assetStr; },
size() { return assetStr.length; }
};
});
}
})
]
}; Hope that helps! |
From the README:
This is not available anywhere, how does one split the output into multiple files without knowledge of how the Webpack compiler works?
Related to FormidableLabs/webpack-stats-plugin#43
The text was updated successfully, but these errors were encountered: