通过注释对异步模块的chunk文件命名

example.js

  1. import("./templates/foo" /* webpackChunkName: "chunk-foo" */ ).then(function(foo) {
  2. console.log('foo:', foo);
  3. })
  4. require.ensure([], function(require) {
  5. var foo = require("./templates/foo");
  6. console.log('foo:', foo);
  7. }, "chunk-foo1");
  8. var createContextVar = "r";
  9. import("./templates/ba" + createContextVar /* webpackChunkName: "chunk-bar-baz" */ ).then(function(bar) {
  10. console.log('bar:', bar);
  11. })