Magento root components plugin
This plugin creates unique chunks for each Root Component in a Magento PWA project and extension.
Example#
Given a RootComponents
directory in a PWA project with the following structure:
Copied to your clipboard1├── Page12│ └── index.js3├── Page24│ └── index.js5└── Page36 └── index.js
This plugin creates unique chunks for Page1
, Page2
, and Page3
.
Further webpack optimization techniques, such as CommonsChunkPlugin
, can be applied if needed.
Example usage#
Copied to your clipboard1// webpack.config.js23const path = require("path");4const { MagentoRootComponentsPlugin } = require("@magento/pwa-buildpack");56module.exports = {7 entry: {8 main: path.join(__dirname, "src"),9 },10 output: {11 path: path.join(__dirname, "dist"),12 filename: "[name].js",13 chunkFilename: "[name].chunk.js",14 },15 plugins: [16 new MagentoRootComponentsPlugin({17 rootComponentsDirs: [path.join(__dirname, "src/RootComponents")], // optional18 manifestFileName: "roots-manifest.json", // optional19 }),20 ],21};