mirror of https://github.com/embarklabs/embark.git
DRY resolve
This commit is contained in:
parent
2c54349c33
commit
cec7dc5750
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue