Fix compilation errors on production

This commit is contained in:
Pranav Raj Sreepuram 2019-08-21 21:37:06 +05:30
parent dc470c1d2c
commit c40814e1b1
2 changed files with 35 additions and 35 deletions

View file

@ -1,18 +1,20 @@
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
/* eslint-disable global-require */
module.exports = api => {
const validEnv = ['development', 'test', 'production'];
const currentEnv = api.env();
const isDevelopmentEnv = api.env('development');
const isProductionEnv = api.env('production');
const isTestEnv = api.env('test');
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
`${'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
'"test", and "production". Instead, received: '}${JSON.stringify(
currentEnv
)}.`
);
}
return {
@ -21,9 +23,9 @@ module.exports = function(api) {
require('@babel/preset-env').default,
{
targets: {
node: 'current'
}
}
node: 'current',
},
},
],
(isProductionEnv || isDevelopmentEnv) && [
require('@babel/preset-env').default,
@ -32,9 +34,9 @@ module.exports = function(api) {
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
]
exclude: ['transform-typeof-symbol'],
},
],
].filter(Boolean),
plugins: [
require('babel-plugin-macros'),
@ -44,32 +46,30 @@ module.exports = function(api) {
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true
}
loose: true,
},
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
useBuiltIns: true
}
useBuiltIns: true,
},
],
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
regenerator: true,
corejs: false
}
corejs: false,
},
],
[
require('@babel/plugin-transform-regenerator').default,
{
async: false
}
async: false,
},
],
[
require('babel-plugin-transform-vue-jsx')
]
].filter(Boolean)
}
}
[require('babel-plugin-transform-vue-jsx')],
].filter(Boolean),
};
};

View file

@ -5,6 +5,10 @@
"@rails/webpacker": "^4.0.7",
"axios": "^0.19.0",
"bourbon": "~4.2.7",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-preset-env": "^1.7.0",
"chart.js": "~2.5.0",
"dotenv": "^8.0.0",
"emojione": "~2.2.7",
@ -37,10 +41,6 @@
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-preset-env": "^1.7.0",
"eslint": "^5.13.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.0.0",