Licence
MIT
Version
1.0.2
Deps
5
Vulns
1
Weekly
0
html-tag-replace-webpack-plugin
è¿æ¯ä¸ä¸ªå¨html-webpack-pluginåºç¡ä¸ä¿æ¹çæä»¶ï¼å¨åæ¥çæä»¶çåºç¡ä¸ï¼æ·»å äºcssåjsèµæºèªå乿³¨å ¥ä½ç½çåè½ã
åè£
npm install html-tag-replace-webpack-plugin
使ç¨
html模æ¿
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="keywords" content="" />
<meta http-equiv="description" content="" />
<title>html-replace-webpack-plugin demo</title>
<!-- inject:css -->
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
webpack.config.js
var HtmlTagReplaceWebpackPlugin = require('html-tag-replace-webpack-plugin')
module.exports = {
...
plugins: [
new HtmlTagReplaceWebpackPlugin({
inject: true,
injectPoint: {
css: ['<!-- inject:css -->', '<!-- endinject -->'],
js: ['<!-- inject:js -->', '<!-- endinject -->']
},
})
]
...
}
webpackç¼è¯çæçhtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="keywords" content="" />
<meta http-equiv="description" content="" />
<title>html-replace-webpack-plugin demo</title>
<!-- inject:css -->
<link href="/static/css/index.css" rel="stylesheet">
<!-- endinject -->
</head>
<body>
<!-- inject:js -->
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/index.js"></script>
<!-- endinject -->
</body>
</html>
API
å ¶ä»APIä¸html-webpack-pluginç¸åã
æ°å¢çAPIï¼
- injectPointï¼
- Type:
Array - Value:
[startTag, endTag] - optionalï¼å¦æä¸è¾ç½æ¤åæ°ï¼å°ä¸html-webpack-pluginåè½ç¸å
- Type: