From cec7dc57507bd8c965c20f5af5c9cfe442acc3aa Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sat, 18 Aug 2018 19:55:34 -0500 Subject: [PATCH] DRY resolve --- lib/pipeline/webpack.config.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/pipeline/webpack.config.js b/lib/pipeline/webpack.config.js index f024c4664..4096b0c2c 100644 --- a/lib/pipeline/webpack.config.js +++ b/lib/pipeline/webpack.config.js @@ -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) } } ]