diff options
| author | rr- <rr-@sakuya.pl> | 2016-04-13 19:02:21 +0200 |
|---|---|---|
| committer | rr- <rr-@sakuya.pl> | 2016-04-13 20:13:10 +0200 |
| commit | d18a8090b12a59cfd21b0ee9d59c04111cee7241 (patch) | |
| tree | 24d56ec1455c13bf09c8c68a8503bd3d9d44fb98 /client | |
| parent | 5796b07908d99edd9224486a48969316779d379b (diff) | |
client/build: transpile ES6 for older browsers
Diffstat (limited to 'client')
| -rw-r--r-- | client/.babelrc | 1 | ||||
| -rw-r--r-- | client/build.js | 7 | ||||
| -rw-r--r-- | client/js/util/polyfill.js | 2 | ||||
| -rw-r--r-- | client/package.json | 3 |
4 files changed, 12 insertions, 1 deletions
diff --git a/client/.babelrc b/client/.babelrc new file mode 100644 index 0000000..9d8d516 --- /dev/null +++ b/client/.babelrc @@ -0,0 +1 @@ +{ "presets": ["es2015"] } diff --git a/client/build.js b/client/build.js index 81fc189..4a13fcb 100644 --- a/client/build.js +++ b/client/build.js @@ -102,11 +102,16 @@ function bundleCss() { } function bundleJs(config) { + const babelify = require('babelify'); const browserify = require('browserify'); const uglifyjs = require('uglify-js'); glob('./js/**/*.js', {}, function(er, files) { const outputFile = fs.createWriteStream('./public/bundle.min.js'); - browserify({debug: config.debug}).add(files).bundle().pipe(outputFile); + let b = browserify({debug: config.debug}); + if (config.transpile) { + b = b.transform(babelify); + } + b.add(files).bundle().pipe(outputFile); outputFile.on('finish', function() { if (!config.debug) { const result = uglifyjs.minify('./public/bundle.min.js'); diff --git a/client/js/util/polyfill.js b/client/js/util/polyfill.js index 5e6101f..01a8148 100644 --- a/client/js/util/polyfill.js +++ b/client/js/util/polyfill.js @@ -1,5 +1,7 @@ 'use strict'; +require('babel-polyfill'); + const keys = Reflect.ownKeys; const reduce = Function.bind.call(Function.call, Array.prototype.reduce); const concat = Function.bind.call(Function.call, Array.prototype.concat); diff --git a/client/package.json b/client/package.json index 8f8fca2..40a1b23 100644 --- a/client/package.json +++ b/client/package.json @@ -6,6 +6,9 @@ "watch": "watch 'npm run build' html js css img --wait=0 --ignoreDotFiles" }, "dependencies": { + "babel-polyfill": "^6.7.4", + "babel-preset-es2015": "^6.6.0", + "babelify": "^7.2.0", "browserify": "^13.0.0", "camelcase": "^2.1.1", "csso": "^1.8.0", |