development.config.js
//引入html-webpack-plugin模块,目的是生成index.html模板
const HtmlWebpackPlugin=require('html-webpack-plugin');
//引入vue-loader中的plugin,才能成功编译.vue文件
const VueLoaderPlugin=require('vue-loader/lib/plugin');
module.exports={
//模式为开发模式
mode: 'development',
//出口
output: {
/*
不需要输出,因为开发模式,编译的bundle.js文件输出内存里
output: path.resolve(__dirname,'dest');
*/
filename: 'bundle.js'
},
//开启调试定位,若文件编译发生错误,定位到具体哪个文件
devtool: 'source-map',
plugins: [
//以index.html为模板编译Html,避免每次都在index.html源文件中引入bundle.js文件
new HtmlWebpackPlugin({
template: 'index.html'
}),
//调用Vue中的plugin,以便成功编译 .vue文件
new VueLoaderPlugin()
]
};
production.config.js
const path=require('path');
const HtmlWebpackPlugin=require(