Module Methods Magic Comments

Magic Comments

Magic comments are a way to add a meaningful bundle name for your lazy loaded bundle. You add it inside the import function as an inline comment:

import(
  /* webpackChunkName: "footer" */
  './footer'
);

Then in your webpack config file:

{
  output: {
    chunkFilename: '[name].lazy-chunk.js';
  }
}

Now at build time, your bundles should include a footer.lazy-chunk.js bundle.

Webpack mode

Last updated