最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - How to prevent webpack from renaming js file? - Stack Overflow

programmeradmin0浏览0评论

I have an angular project that is using webpack. I am also lazy loading several components of my application. 2 of those components use the d3 library. Ever since I added the second component, the d3 library gets lazy loaded separately using the filename node_modules_d3_index_js.js which represents its path node_modules/d3/index.js. Is there a way to rename this to d3.js or d3.min.js.

I have this in my webpack config which seems to be adjusting how things are packed into files and their names:

optimization: {
  splitChunks: {
    minChunks: 3,
  },
  chunkIds: 'named',
}

I have an angular project that is using webpack. I am also lazy loading several components of my application. 2 of those components use the d3 library. Ever since I added the second component, the d3 library gets lazy loaded separately using the filename node_modules_d3_index_js.js which represents its path node_modules/d3/index.js. Is there a way to rename this to d3.js or d3.min.js.

I have this in my webpack config which seems to be adjusting how things are packed into files and their names:

optimization: {
  splitChunks: {
    minChunks: 3,
  },
  chunkIds: 'named',
}
Share Improve this question edited Nov 26, 2024 at 15:37 rtaft asked Nov 19, 2024 at 22:13 rtaftrtaft 2,3781 gold badge18 silver badges36 bronze badges 1
  • Please share your webpack configuration – Dillon Benson Commented Nov 19, 2024 at 22:17
Add a comment  | 

1 Answer 1

Reset to default 0

This seems to work well

optimization: {
  splitChunks: {
    minChunks: 3,
    chunks: "all",
    name(module, chunks, cacheGroupKey) {
      if (module.identifier().indexOf("node_modules/d3") > 0) {
          return 'd3';
      }
      return null;
    }
  },
  chunkIds: 'named',
},
发布评论

评论列表(0)

  1. 暂无评论