const path= require('path');
const webpack=require('webpack');
const VueLoaderPlugin=require('vue-loader/lib/plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const isDev=process.env.NODE_ENV==='development'
const config = {
target:'web',
entry:path.join(__dirname,'src/index.js'),
output:{
filename:'bunder.js',
path:path.join(__dirname,'dist')
},
devtool: 'inline-source-map',
devServer: {
compress:false,
contentBase: './dist'
},
module:{
rules:[
{
test:/\.vue$/,
loader:'vue-loader'
},
{
test:/\.css$/,
use:[
'style-loader',
'css-loader'
]
}
]
},
resolve:{
alias:{
'vue$':'vue/dist/vue.min.js'
}
},
plugins:[
new webpack.DefinePlugin({
'process.env':{
NODE_ENV:isDev ? '"development"' : '"production"'
}
}),
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
],
}
if(isDev){
config.devServer={
port:8080,
host:'0.0.0.0',
overlay:{
errors:true
}
}
}
module.exports=config
webpack:跑个vue的基本配置
猜你喜欢
转载自blog.csdn.net/weixin_40301750/article/details/88045407
今日推荐
周排行