I keep getting error whenever I want to build a file. What is a reason of it? It seems that .vue file is not recognizable by webpack, but webpack configuration file looks properly. webpack error
bundle-app.js 189 kB 1 [emitted] app
+ 12 hidden modules
ERROR in Unexpected token >
@ ./app/application.js 7:11-31
webpack.config.js
var path = require("path");
module.exports = {
context: path.join(__dirname, 'src'),
entry: {
app: './app/application.js'
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle-[name].js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
include: /src/,
query: {
presets: ["es2015"]
}
},
{
test: /\.vue$/,
loader: 'vue',
},
]
},
vue: {
loaders: {
js: 'babel'
}
}
}
package.json
"devDependencies": {
"webpack": "~2.2.1",
"babel-core": "~6.23.1",
"babel-loader": "~6.3.1",
"babel-preset-es2015": "~6.22.0",
"sass-loader": "~6.0.0",
"node-sass": "~4.5.0",
"extract-text-webpack-plugin": "~2.0.0-rc.3",
"vue-template-compiler": "~2.2.4",
"css-loader": "~0.27.3",
"vue-loader": "~11.1.4"
},
"dependencies": {
"vue": "~2.2.4"
}
}
app/application.js
import Vue from 'vue'
import App from './app.vue'
new Vue({
el: 'body',
component: { App }
})
app/app.vue
<template>
<div id="app">
</div>
</template>
<script>
export default {
data () {
return {
msg: 'Hello from vue-loader!'
}
}
}
.babelrc
file.It should looks something like this{ "presets": ["es2015"], "comments": false }
For more info check here github.com/bedakb/vuewp/blob/master/.babelrc Also consider to NOT mount vue app to body tag, – Radiolarian-loader
keyword.Try change thisloader: 'vue'
to thisloader: 'vue-loader'
– Radiolarian</script>
after the export default {} ...? – Adnopozcomponent: { App }
is should be components - plural. – Radiolarian