replace html-webpack-plugin injected js、css url
webpack1+
npm install injectjscss-template-html-webpack-plugin
or
yarn add injectjscss-template-html-webpack-plugin
const injectJsCssTemplateHtmlWebpackPlugin = require('injectjscss-template-html-webpack-plugin');
const htmlWebpackPlugin = require('html-webpack-plugin');
/* webpack config add */
plugin: [
new htmlWebpackPlugin({....}),
new injectJsCssTemplateHtmlWebpackPlugin(options), // this must be behind the html-webpack-plugin
....
]
Object or Array
-
injectTemplateId - number
when html-wepack-plugin is multiple, injectJsCssTemplateHtmlWebpackPlugin will through injectTemplateId match, and the options must be Array.
html-webpack-plugin option must add the same injectTemplateId
example:
plugin: [
new htmlWebpackPlugin({
injectTemplateId: 0,
....
}),
new htmlWebpackPlugin({
injectTemplateId: 1,
....
}),
new injectJsCssTemplateHtmlWebpackPlugin([{
injectTemplateId: 0,
...
},{
injectTemplateId: 1,
...
}])
]
- jstemplate - function
function(everypath){
.....
return path;
}
- csstemplate - function
function(everypath){
.....
return path;
}