Skip to content

emcty/custom-webpack-named-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-plugin

hashedPlugin

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'
        }
      }
    })
  ]
  

namedPlugin

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'
      }
    })
  ]

About

a webpack modules custom name plugin"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published