Commit df72d65a authored by Mike Greiling's avatar Mike Greiling

compile es6/es2015 with babel

parent 4c5ff1d0
require('./hello_world'); var HelloWorld = require('./hello_world').default;
var message = new HelloWorld('webpack');
message.sayHello();
/* eslint-disable no-console */
console.log('hello world!');
/* eslint-disable no-undef, no-alert */
export default class HelloWorld {
constructor(name) {
this.message = `Hello ${name}!`;
}
sayHello() {
alert(this.message);
}
}
...@@ -22,6 +22,19 @@ var config = { ...@@ -22,6 +22,19 @@ var config = {
filename: IS_PRODUCTION ? '[name]-[chunkhash].js' : '[name].js' filename: IS_PRODUCTION ? '[name]-[chunkhash].js' : '[name].js'
}, },
module: {
loaders: [
{
test: /\.es6$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
plugins: [ plugins: [
// manifest filename must match config.webpack.manifest_filename // manifest filename must match config.webpack.manifest_filename
// webpack-rails only needs assetsByChunkName to function properly // webpack-rails only needs assetsByChunkName to function properly
...@@ -32,7 +45,11 @@ var config = { ...@@ -32,7 +45,11 @@ var config = {
modules: false, modules: false,
assets: true assets: true
}) })
] ],
resolve: {
extensions: ['', '.js', '.es6', '.js.es6']
}
} }
if (!IS_PRODUCTION) { if (!IS_PRODUCTION) {
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
"eslint-report": "npm run eslint -- --format html --output-file ./eslint-report.html" "eslint-report": "npm run eslint -- --format html --output-file ./eslint-report.html"
}, },
"dependencies": { "dependencies": {
"babel-core": "^6.17.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.16.0",
"stats-webpack-plugin": "^0.4.2", "stats-webpack-plugin": "^0.4.2",
"webpack": "^1.13.2", "webpack": "^1.13.2",
"webpack-dev-server": "^1.16.2" "webpack-dev-server": "^1.16.2"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment