(四)webpack打包html资源


使用html-webpack-plugin插件,可以在打包后自动生成一个index.html文件,这个index.html文件里会把打包后的静态资源引入。

相关配置如下面所受

const path = require('path') const htmlWebpackPlugin = require('html-webpack-plugin') module.exports = { entry: "./src/main.js", output:{ filename: 'index.js', path:path.resolve(__dirname, 'build') }, module:{ }, plugins:[ new htmlWebpackPlugin({ template:"./src/index.html" }) ], mode:'development' }

其中template为指定打包的html使用的模板。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM