ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLo
aderPlugin in your webpack config.
@ ./src/index.js 2:0-27 8:17-20
ERROR in ./src/app.vue?vue&type=style&index=0&lang=css& 16:0
Module parse failed: Unexpected character '#' (16:0)
You may need an appropriate loader to handle this file type.
|
|
> #test{
| color: red;
| }
@ ./src/app.vue 4:0-63
@ ./src/index.js
ERROR in ./src/app.vue?vue&type=template&id=5ef48958& 2:0
Module parse failed: Unexpected token (2:0)
You may need an appropriate loader to handle this file type.
|
> <div id="test">{{text}}</div>
|
@ ./src/app.vue 1:0-82 11:2-8 12:2-17
@ ./src/index.js
------------------------------------
module:{
rules:[
{
test:/.vue$/,
loader: 'vue-loader'
}
]
}
这个已经配置了
const path = require('path') const VueLoaderPlugin = require('vue-loader/lib/plugin'); module.exports = { 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$/, loader: 'css-loader' } ] }, plugins: [new VueLoaderPlugin()] }
第一步在module.exports上边引入vue-loader插件:const VueLoaderPlugin = require('vue-loader/lib/plugin');
第二步:在module.exports最下边添加:
plugins: [new VueLoaderPlugin()]
我觉得你可以这样:
在 webpack.config.js 中加入
... const { VueLoaderPlugin } = require('vue-loader'); module.exports = { ... plugins: [ new VueLoaderPlugin(), ], };
https://vue-loader.vuejs.org/zh/guide/#%E6%89%8B%E5%8A%A8%E8%AE%BE%E7%BD%AE
新版本的vue-loader 要求必须手动添加vueLoaderPlugin. 老师的那个配置是老版本的。
我建议去老师的这个项目的git,https://github.com/Jokcy/vue-todo-tech/blob/master/package.json
直接copy package.json 来install。 这样就和老师一样了