webpack-transform-modules-plugin
v0.4.4
Published
webpack transform modules plugin
Downloads
660
Readme
webpack-transform-modules-plugin
A webpack plugin for babel-plugin-transform-modules. It is used to handle babel-plugin-transform-modules
'transform-modules' options in node_modules.
Note: This plugin only works with babel-loader
and vue-loader
.
Install
npm i webpack-transform-modules-plugin --save-dev
Usage
var TransformModulesPlugin = require('webpack-transform-modules-plugin')
module.exports = {
// ...
module: {
rules: [
// ...
{
test: /\.js$/,
loader: 'babel-loader'
// this plugin will be include the packages "transformModules" config
// eg: {"transformModules": {"a": {...}}} // in package.json
// the current rule's options plugins will be like:
/*
`[require('babel-plugin-transform-modules'), {
'a': {
...
}
}]`
*/
}
// ...
]
},
plugins: [
new TransformModulesPlugin()
]
}
Options
new TransformModulesPlugin({
transformModules: {
a: {
transform: 'a/${member}'
},
b: null
}
})
In this demo, this plugin will load a
and b
packages "transformModules" config in each package.json and it will load sub packages "transformModules" configs too.
transformModules {Object}
defaultundefined
, application initbabel-plugin-transform-modules
'transform-modules' options, if it isundefined
then this plugin will gettransformModules
value inpackage.json
as the init config.