(四)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