Reputation: 1040
this is my package.json
:
"scripts": {
"start": "webpack-dev-server --hot --inline",
},
"license": "",
"devDependencies": {
"babel-core": "~6.4.5",
"babel-loader": "^6.2.1",
"css-loader": "^0.23.1",
"raw-loader": "~0.5.1",
"style-loader": "^0.13.0",
"webpack": "~1.12.12",
"webpack-dev-server": "~1.14.1"
},
"dependencies": {
"angular": "~1.4.9"
}
this is my webpack.config.js
:
var path = require('path')
module.exports = {
context: path.resolve(__dirname,'public'),
entry: './entry.js',
resolve: {
root: [__dirname + "/public"]
},
output:{
path: path.resolve(__dirname, "public"),
filename:'bundle.js',
publicPath: '/public/'
},
module:{
loaders:[
{ test: path.join(__dirname,'public'),loader:'babel'},
{ test: /\.css$/, loader:'style!css'}
]
},
devtool: '#inline-source-map'
}
this is my entry.js
:
document.write('webpack!')
import 'angular';
this is the error i am getting:
ERROR in ./public/entry.js Module parse failed: /home/guy/itay/Develop/webpack-tut/node_modules/babel-loader/index.js!/home/guy/itay/Develop/webpack-tut/public/entry.js Line 3: Unexpected token You may need an appropriate loader to handle this file type.
| document.write('webpack!');
|
| import 'angular';
node version: 5.4.1,
npm version: 3.3.12
Upvotes: 0
Views: 1565
Reputation: 1040
my problem was that i used babel ^6.0.0 and i did not set the presets option in my loader like this:
query: {
presets: ['es2015', 'stage-2']
}
there is the link that helped me through that: https://medium.com/@malyw/how-to-update-babel-5-x-6-x-d828c230ec53#.xn8bkagxz
Upvotes: 0