babel used in webpack to convert es2015 to es5

master endingwebpack
Matt Huntington 9 years ago
parent 1683dd77d1
commit f6942f17ee

@ -1,5 +1,8 @@
import asdf, {myFunc2 as wee} from './mylib.js' import asdf, {myFunc2 as wee, Foo} from './mylib.js'
var a = new Foo();
a.bar();
asdf(); asdf();
wee(); wee();
console.log('awesome'); console.log('awesome');

@ -2,9 +2,18 @@ const myFunc = function(){
console.log('included!'); console.log('included!');
} }
const myFunc2 = function(){ const myFunc2 = function(){
console.log('also included'); var a = 1;
var b = 2;
var c = {a,b};
console.log(c);
}
class Foo {
bar(){
console.log('ya');
}
} }
export default myFunc; export default myFunc;
export { myFunc2 } export { myFunc2, Foo }

@ -17,6 +17,9 @@
}, },
"homepage": "https://github.com/mahuntington/react-redux#readme", "homepage": "https://github.com/mahuntington/react-redux#readme",
"devDependencies": { "devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"webpack": "^2.4.1" "webpack": "^2.4.1"
} }
} }

@ -1,6 +1,19 @@
module.exports = { module.exports = {
entry: './js/index.js', entry: './js/index.js',
output: { output: {
filename: 'dist/bundle.js' filename: 'dist/bundle.js'
} },
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: {
loader: 'babel-loader',
options: {
presets: ["es2015"]
}
}
}
]
}
}; };

Loading…
Cancel
Save