preface

Yesterday, we re-packaged the drainage page of our company, and we met a problem.

How to add a prefix that can follow filename changes when webpack is cut.

rendering

To solve the path

  • GG Dafa + Webpack official document

The official documentation does provide corresponding knowledge, as explained below

Basically, [Request] gets the actual parsed file name instead of the default index increment.

Code implementation

[magic-Comments]

/ / register
const IntroRegister = categoryName= > {
  return (a)= > import(/* webpackChunkName:"[request]" */ `@/views/${categoryName}/intro-register/intro-register.vue`);
};
Copy the code

conclusion

The advantage of this is that the purpose of file cutting is achieved, and the loaded resource file is clear and has a name, instead of the default 0.js,1.js