DRY resolve
This commit is contained in:
parent
2c54349c33
commit
cec7dc5750
|
@ -63,6 +63,16 @@ const entry = Object.keys(embarkAssets)
|
|||
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
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
@ -90,28 +100,28 @@ const base = {
|
|||
options: {
|
||||
plugins: [
|
||||
[
|
||||
require.resolve('babel-plugin-module-resolver'), {
|
||||
'babel-plugin-module-resolver', {
|
||||
'alias': embarkAliases
|
||||
}
|
||||
],
|
||||
[
|
||||
require.resolve('@babel/plugin-transform-runtime'), {
|
||||
'@babel/plugin-transform-runtime', {
|
||||
corejs: 2,
|
||||
useESModules: true
|
||||
}
|
||||
]
|
||||
],
|
||||
].map(resolve),
|
||||
presets: [
|
||||
[
|
||||
require.resolve('@babel/preset-env'), {
|
||||
'@babel/preset-env', {
|
||||
modules: false,
|
||||
targets: {
|
||||
browsers: ['last 1 version', 'not dead', '> 0.2%']
|
||||
}
|
||||
}
|
||||
],
|
||||
require.resolve('@babel/preset-react')
|
||||
]
|
||||
'@babel/preset-react'
|
||||
].map(resolve)
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue