Vue项目打包成一个HTML文件包含CSSJSsvgpngttfeotwoff等
-
安装
html-webpack-plugin插件npm install html-webpack-plugin --save-dev -
在
webpack.config.js中引入插件const HtmlWebpackPlugin = require('html-webpack-plugin'); -
配置
webpack.config.js文件module.exports = { //...省略其他配置 plugins: [ new HtmlWebpackPlugin({ template: './public/index.html', //指定模板文件路径 filename: 'index.html', //生成的HTML文件名 minify: { removeComments: true, //移除HTML中的注释 collapseWhitespace: true, //删除空白符和换行符 removeAttributeQuotes: true //移除属性上的引号 } }) ] } -
执行
npm run build打包命令,生成的dist目录下会有一个index.html文件,其中包含了所有的CSS、JS、svg、png、ttf、eot、woff等资源文件
原文地址: https://www.cveoy.top/t/topic/dxAp 著作权归作者所有。请勿转载和采集!