0.0.2 • Published 7 years ago
custom-webpack-named-plugin v0.0.2
custom-webpack-named-plugin
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.
Mode of use
npm i --save-dev custom-webpack-named-plugin yarn add --dev custom-webpack-named-pluginhashedPlugin
if you use hashedModuleIds of webpack>=4 or HashedModuleIdsPlugin of webpack<4
let CustomHashedPlugin = require("custom-webpack-named-plugin").hashedPluginthe default type of mapping object is String webpack.config.js
plugins: [
new CustomHashedPlugin({
mapping:{
type: 'String',
match: {
'./src/index.js':'customName'
}
}
})
]
namedPlugin
if you use namedModules of webpack>=4 or Namedmodulesplugin of webpack<4
let CustomNamedPlugin = require("custom-webpack-named-plugin").namedPluginwebpack.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'
}
})
]