const?path?=?require('path')
const??{?VueLoaderPlugin?}??=?require('vue-loader')
const?HTMLPlugin?=?require('html-webpack-plugin')
const?webpack?=?require('webpack')
const?isDev?=?process.env.NODE_ENV?===?'development'
const?config?=?{
????target:?'web',
????entry:?path.join(__dirname,?'src/index.js'),
????output:?{
????????filename:?'bundle.js',
????????path:?path.join(__dirname,?'dist')
????},
????module:{
????????rules:?[
????????????{
??????????????test:?/\.vue$/,
??????????????use:?[
??????????????????{loader:?'vue-loader'}
??????????????]
????????????},
????????]
????},
????plugins:?[
????????new?VueLoaderPlugin(),
????????new?webpack.DefinePlugin({
????????????'process.env':?{
????????????????NODE_ENV:?isDev???'"development"'?:?'"production"'
????????????}
????????}),
????????new?HTMLPlugin()
????]
}
if(isDev){
??config.devServer?=?{
??????port:?8000,
??????host:?'0.0.0.0',
??????overlay:?{
??????????errors:?true
??????},
??????open:?true
??}
}
module.export?=?config
2018-06-20
你的報錯應該是css內容無法解析吧,15版的?vue-loader?會出現這種情況,你還需要把 { ????test;?/\.css$/, ????loader:?'css-loader' } 也加入到?rules?數組里面。2018-05-26
方法一: 把vue-loader版本替換為14
方法二: 根據vue-loader官方提供的15版本的聲明方法,定義plugin。
const?VueLoaderPlugin?=?require('vue-loader/lib/plugin')?? module.exports?=?{ ??module:?{ ????rules:?[ ??????//?...?other?rules ??????{ ????????test:?/\.vue$/, ????????loader:?'vue-loader' ??????} ????] ??}, ??plugins:?[ ????new?VueLoaderPlugin()???//15版本需指定plugin ??]}2018-05-25
把vue-loader的版本替換成^14.2.0試一下