代码拉取完成,页面将自动刷新
同步操作将从 mirrors_oyslin/replace-in-file-webpack-plugin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
This is a webpack plugin that can replace content in file(s) after compilation is done. This is useful when you want to replace content in any kind of files(html, css, js etc) which are not processed by loaders.
Install the plugin with npm:
$ npm install replace-in-file-webpack-plugin --save-dev
Add the plugin to your webpack and config as follows:
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const webpackConfig = {
entry: 'index.js',
output: {
path: __dirname + '/dist',
filename: 'index_bundle.js'
},
plugins: [
new ReplaceInFileWebpackPlugin([{
dir: 'dist',
files: ['index.html', 'main.html'],
rules: [{
search: '@class',
replace: 'main-class'
},{
search: /@title/,
replace: 'webpack'
}]
}, {
dir: 'dist/style',
test: /\.html$/,
rules: [{
search: /version/ig,
replace: '1.0.0'
},{
search: '@title',
replace: function(match){
}
}]
},{
dir: 'dist/style',
test: [/\.css$/, /\.txt/],
rules: [{
search: /version/ig,
replace: '1.0.0'
},{
search: '@title',
replace: 'webpack'
}]
}])
]
};
You can pass an array of configuration options to ReplaceInFileWebpackPlugin
. Each configuration has following items:
dir
: Optional. Base dir to find the files, if not provided, use the root of webpack context.files
: Optional. Files in dir
to find for replacement.test
: Optional. Regex expression or Regex expressions array to match files in dir
.rules
: Required. Replace content rules array. Each rule has search
and replace
properties.search
: Required. String or Regex expression used for searching content in files.replace
: Required. String or funcion used for replacing the searching content.This project is licensed under MIT.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。