Vue2.0 webpack 配置html-webpack-plugin无报错 但依旧失败——一个空格引发的惨案

今天刚开始学习Vue2.0,在配置html-webpack-plugin时,没有报错,但效果就是不显示

查了半天大小写,无错

// 导入HTML插件,得到一个构造函数
const HtmlPlugin = require('html-webpack-plugin');

// 创建HTML插件的实例对象
const htmlPlugin = new HtmlPlugin({
	template: './src/index.html', //指定原文件的存放路径
	filename: './index.html', //指定生成的文件的存放路径
});

// 使用 node.js的导出语法,向外导出webpack对象
module.exports = {
	// mode 节点的可选值有两个,分别是development/production
	mode: 'development',
	// entry:'指定要处理哪个文件'
	entry: path.join(__dirname, './src/index1.js'),
	output: {
		path: path.join(__dirname, 'dist'),
		filename: 'bundle.js',
	},

	// 插件的数组,将来的webpack 运行时会调用这个插件
	plugins: [htmlPlugin], //通过plugin 节点,使得htmlPlugin插件生效

原因:在package.json 中配置scripts时,在serve后面多粘贴了一个空格

"scripts": {
		"dev": "webpack serve"
	},

如果你也遇到了这样的不报错,但效果出不来的情况,可以按照这个思路检查

zsbd:html-webpack-plugin 是 webpack 中的 HTML 插件,可以通过此插件自定制 index.html 页面的内容。 需求:通过 html-webpack-plugin 插件,将 src 目录下的 index.html 首页,复制到项目根目录中一份

猜你喜欢

转载自blog.csdn.net/qq_36722315/article/details/124934862
今日推荐