summaryrefslogtreecommitdiff
path: root/.babelrc.js
diff options
context:
space:
mode:
Diffstat (limited to '.babelrc.js')
-rw-r--r--.babelrc.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/.babelrc.js b/.babelrc.js
new file mode 100644
index 00000000000..27caf378b99
--- /dev/null
+++ b/.babelrc.js
@@ -0,0 +1,38 @@
+const BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || null;
+
+const presets = [
+ [
+ '@babel/preset-env',
+ {
+ modules: false,
+ targets: {
+ ie: '11',
+ },
+ },
+ ],
+];
+
+// include stage 3 proposals
+const plugins = [
+ '@babel/plugin-syntax-dynamic-import',
+ '@babel/plugin-syntax-import-meta',
+ '@babel/plugin-proposal-class-properties',
+ '@babel/plugin-proposal-json-strings',
+];
+
+// add code coverage tooling if necessary
+if (BABEL_ENV === 'coverage') {
+ plugins.push([
+ 'babel-plugin-istanbul',
+ {
+ exclude: ['spec/javascripts/**/*', 'app/assets/javascripts/locale/**/app.js'],
+ },
+ ]);
+}
+
+// add rewire support when running tests
+if (BABEL_ENV === 'karma' || BABEL_ENV === 'coverage') {
+ plugins.push('babel-plugin-rewire');
+}
+
+module.exports = { presets, plugins };