I've recently put together a sample project using webpack and started incorporating babel. Despite trying out various configurations from different sources, I'm still encountering issues with getting it to work properly.
Below is my webpack.config.js:
const path=require('path');
const config={
entry:'./src/index.js',
output:{
path:path.resolve(__dirname,'build'),
filename:'bundle.js'
},
module: {
loaders:[
{
test:'/\.js?$/',
loader: "babel",
exclude: /node_modules/,
query: {
presets: ['es2015'],
}
}
]
}
};
module.exports=config;
.babelrc:
{
"presets":["es2015"]
}
package.json:
{
"name": "webpack2",
"version": "1.0.0",
"description": "This is first Webpack 2 project",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"author": "Viraj Nimbalkar",
"license": "",
"devDependencies": {
"babel-core": "^6.23.1",
"babel-loader": "^6.4.0",
"babel-preset-env": "^1.2.1",
"babel-preset-es2015": "^6.22.0",
"webpack": "^2.2.1"
}
}
Output in bundle.js:
(Output content in bundle.js)
Can anyone assist me in pinpointing the issue with my setup?
Additionally, I'm unclear on the distinction between .babelrc and the query within the loader configuration.