研究了好久好久..为什么呀
ERROR in ./src/app.vue
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <template>
| <div id="text">{{text}}</div>
|
@ ./src/index.js 2:0-27
ERROR in ./src/app.vue
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <template>
| <div id="text">{{text}}</div>
|
@ ./src/index.js 2:0-27
2018-05-29
vue-loader版本过高了,语法结构不一样的,建议换低版本,或者如下面写法,亲测可用
const path = require("path")
const {VueLoaderPlugin } = require("vue-loader")
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()
]
}提示的意思是解析不了vue文件,需要在webpack.config.js中添加vue-loader来解析vue文件,然后,最新的vue-loader v15版本,必须加上面说的vue-loader的一个插件,去官网看。从官网上搬下来的,针对最新v15版本的vue-loader如下,然后运行,如果还报错,说识别不了#,可能是不能解析css,需要将css解析部分添上,我这样做,就可以正常build了
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
module: {
rules: [
// ... other rules
{
test: /\.vue$/,
loader: 'vue-loader'
}
]
},
plugins: [
// make sure to include the plugin!
new VueLoaderPlugin()
]
}
{
test: /\.css$/,
use:[
'style-loader',
'css-loader',
]
},举报