DRY resolve

This commit is contained in:
Michael Bradley, Jr 2018-08-18 19:55:34 -05:00
parent 2c54349c33
commit cec7dc5750
1 changed files with 16 additions and 6 deletions

View File

@ -63,6 +63,16 @@ const entry = Object.keys(embarkAssets)
return obj; return obj;
}, {}); }, {});
function resolve(pkgName) {
if (Array.isArray(pkgName)) {
const _pkgName = pkgName[0];
pkgName[0] = require.resolve(_pkgName);
return pkgName;
} else {
return require.resolve(pkgName);
}
}
// base config // base config
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -90,28 +100,28 @@ const base = {
options: { options: {
plugins: [ plugins: [
[ [
require.resolve('babel-plugin-module-resolver'), { 'babel-plugin-module-resolver', {
'alias': embarkAliases 'alias': embarkAliases
} }
], ],
[ [
require.resolve('@babel/plugin-transform-runtime'), { '@babel/plugin-transform-runtime', {
corejs: 2, corejs: 2,
useESModules: true useESModules: true
} }
] ]
], ].map(resolve),
presets: [ presets: [
[ [
require.resolve('@babel/preset-env'), { '@babel/preset-env', {
modules: false, modules: false,
targets: { targets: {
browsers: ['last 1 version', 'not dead', '> 0.2%'] browsers: ['last 1 version', 'not dead', '> 0.2%']
} }
} }
], ],
require.resolve('@babel/preset-react') '@babel/preset-react'
] ].map(resolve)
} }
} }
] ]