1.0.0 • Published 3 years ago
jfsource-helper-plugins v1.0.0
jfsource-helper-plugins
介绍 该插件是允许你用数组配置的方式集成组件,该类组件主要运用在webpack打包前,对源代码进行预处理, 比如对img标签进行自定义的处理等
安装
npm i jfnode-compile-plugin --save -D
npm i jfsource-helper-plugins --save -D
npm i modify-source-webpack-plugin --save -D
使用
找到 webpack 配置文件webpack.config.js
的 plugins 配置项,新增:
const { ModifySourcePlugin } = require('modify-source-webpack-plugin')
const imageHelper = require('../custom-config/image-helper')
const sourceHelperPlugins = require('../custom-config/source-helper-plugins')
plugins: [
new ModifySourcePlugin({
rules: [
{
test: /\.jsx$/,
modify: (source, filename) => {
return sourceHelperPlugins(source, [
{
plugin: nodesCompile,
options: {
startTarget: '//start',
endTarget: '//end'
}
}
])
}
}
]
})
]
1.0.0
3 years ago