[Vuejs]-How to change a chunk names generated by VuePress

0👍

You can use vuepress-plugin-named-chunks plugin to modify the name and path of js chunks generated by VuePress for each page…

  1. Install the plugin
  2. Change .vuepress\config.js
module.exports = {
  plugins: [
    [
      "named-chunks",
      {
        pageChunkName: function(page) {
          let chunkPath = page.path.substring(1) + page.key;
          // console.log(chunkPath);
          return chunkPath;
        }
      }
    ]
  ]
};

Internally it is using webpackChunkName “magic comment”

If your pageChunkName returns string with not just file name but also with path, it is important to not include leading slash – guide/readme.js will work, /guide/readme.js will not…..

Leave a comment