This is a custom module plugin package for webpack. it allows you to command your module name in your own way.this is very useful for module reusability, especially in the production environment.
npm i --save-dev custom-webpack-named-plugin
yarn add --dev custom-webpack-named-plugin
if you use hashedModuleIds of webpack>=4 or HashedModuleIdsPlugin of webpack<4
let CustomHashedPlugin = require("custom-webpack-named-plugin").hashedPlugin
the default type of mapping object is String webpack.config.js
plugins: [
new CustomHashedPlugin({
mapping:{
type: 'String',
match: {
'./src/index.js':'customName'
}
}
})
]
if you use namedModules of webpack>=4 or Namedmodulesplugin of webpack<4
let CustomNamedPlugin = require("custom-webpack-named-plugin").namedPlugin
webpack.config.js
plugins: [
new CustomNamedPlugin({
mapping:{
type: 'String',
match: {
'./src/index.js':'customName'
}
}
})
]
it also allows you use RegExp type
webpack.config.js
plugins: [
new CustomNamedPlugin({
mapping:{
type: 'RegExp'
'./src/(\\w+).js':'$1'
}
})
]