ERROR in ./src/app.vue
Module build failed (from ./node_modules/vue-loader/index.js):
TypeError: Cannot read property 'vue' of undefined
at Object.module.exports (D:\vuePro\vue-ssr-tech\node_modules\vue-loader\lib\loader.js:61:18)
@ ./src/index.js 2:0-27 8:21-24
3q,还是插件的版本有问题。
关键的代码:webpack.config.js中
const path=require('path')
const isDev=process.env.NODE_ENV ==='development'
const HTMLPlugin=require('html-webpack-plugin')
const webpack=require('webpack')
const config = {
target:'web',
entry: path.join(__dirname,'src/index.js'),
output:{
filename:'bundle.js',
path:path.join(__dirname,'dist')
},
module:{
rules:[
{
test:/\.vue$/,
loader:'vue-loader'
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test:/\.styl/,
use:[
'style-loader',
'css-loader',
'stylus-loader'
]
},
{
test: /\.(gif|jpg|jpeg|png|svg)$/,
use: [
{
loader:'url-loader',
options:{
limit:1024,
name:'[name]-a.[ext]'
}
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env':{
NODE_ENV:isDev?'"development"':'"production"'
}
}),
new HTMLPlugin()
]
}
if(isDev){
config.devtool="#cheap-module-eval-source-map"
config.devServer={
port:8000,
host:'0.0.0.0',
overlay:{
errors:true
},
open:true,
hot:true
}
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
)
}
module.exports=config