1.html-webpack-plugin
该插件主要作用是在release时,自动向index.html 文件中写入 <script>xx/xx/bundle.js</script>。
参数配置:
output: { path: __dirname + "/",//代表webpack 打包后的文件保存路径 filename: ‘bundle.js‘, //打包文件的名称 publicPath: ‘./‘ //打包文件在<script></script>中的路径,如 <script type="text/javascript" src="./bundle.js"></script> //如果publicPath:‘./home‘,script的src 为 ./home/bundle.js } plugins: [ new HtmlWebpackPlugin({ filename: ‘./index.html‘, //需要写入的文件路径及名称 template: ‘./index.html‘, inject: "body", //注入到html的那个节点上 hash: true }) ]
原文:http://www.cnblogs.com/rengised/p/6245161.html