summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2018-10-02 16:11:53 -0500
committerMike Greiling <mike@pixelcog.com>2018-10-02 16:11:53 -0500
commit5f53269f0e4cb819c59ecd173496d6202feb7f7a (patch)
tree815bb6896b025ff7c25984cc9459ef88ac2bd6b7
parentc0dffdff401ce6d78b9373bdbbc50ee242a2bf24 (diff)
downloadgitlab-ce-5f53269f0e4cb819c59ecd173496d6202feb7f7a.tar.gz
Update babelrc with comments
-rw-r--r--.babelrc35
-rw-r--r--.babelrc.js38
2 files changed, 38 insertions, 35 deletions
diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index 83172a47753..00000000000
--- a/.babelrc
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "presets": [
- [
- "@babel/preset-env",
- {
- "modules": false,
- "targets": {
- "ie": "11"
- }
- }
- ]
- ],
- "plugins": [
- "@babel/plugin-syntax-dynamic-import",
- "@babel/plugin-syntax-import-meta",
- "@babel/plugin-proposal-class-properties",
- "@babel/plugin-proposal-json-strings"
- ],
- "env": {
- "karma": {
- "plugins": ["babel-plugin-rewire"]
- },
- "coverage": {
- "plugins": [
- [
- "babel-plugin-istanbul",
- {
- "exclude": ["spec/javascripts/**/*", "app/assets/javascripts/locale/**/app.js"]
- }
- ],
- "babel-plugin-rewire"
- ]
- }
- }
-}
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 };