0.4.4 • Published 6 years ago
webpack-transform-modules-plugin v0.4.4
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-devUsage
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 isundefinedthen this plugin will gettransformModulesvalue inpackage.jsonas the init config.