【发布时间】:2024-04-30 01:10:03
【问题描述】:
我尝试使用 HtmlWebPackPlugin 来生成我的 index.html 所以...
- 我启动了一个新项目
vue init webpack-simple#1.0 vue-html-webpack - 安装
npm i -D html-webpack-plugin - 将
index.html重命名为entry-template.html - 配置
webpack.config.js..
我添加..
plugins: [
new HtmlWebpackPlugin({
template: 'entry-template.html',
environment: process.env.NODE_ENV
})
],
但是网页我启动应用程序npm run dev,返回404(我想是找不到index.html)
我的entry-template.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>GitSkills</title>
</head>
<body>
<div id="app"></div>
</body>
</html>
完整的source here
结果 -> https://vue-html-webpack-ogqlguavxx.now.sh/
问题
如何在 Vue 1.0 中使用 HtmlWebpackPlugin?
【问题讨论】:
-
你能提供一个链接来克隆 repo 吗?
标签: webpack vue.js html-webpack-plugin vue-loader