From 71a03353fed8cec3ea9bd4e0347b77554a0a7a5a Mon Sep 17 00:00:00 2001 From: Joel Chen Date: Wed, 19 Feb 2020 19:47:24 -0800 Subject: [PATCH] detect Electrode webpack config generated by user and use directly --- .../config/webpack/util/generate-config.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/xarc-app-dev/config/webpack/util/generate-config.js b/packages/xarc-app-dev/config/webpack/util/generate-config.js index f685aaac89..0017fbbe27 100644 --- a/packages/xarc-app-dev/config/webpack/util/generate-config.js +++ b/packages/xarc-app-dev/config/webpack/util/generate-config.js @@ -9,6 +9,9 @@ const optionalRequire = require("optional-require")(require); const Path = require("path"); const _ = require("lodash"); const logger = require("@xarc/app/lib/logger"); +const ck = require("chalker"); + +const xarcWebpackConfig = Symbol("Electrode X webpack config"); function searchUserCustomConfig(options) { let customConfig; @@ -101,12 +104,22 @@ function generateConfig(opts, archetypeControl) { if (customConfig) { if (_.isFunction(customConfig)) { config = customConfig(composer, options, compose); + } else if (customConfig[xarcWebpackConfig]) { + console.error(ck`WARNING: +WARNING: Your custom webpack config file returned a config that contains Electrode webpack config. +WARNING: Assuming you want Electrode to start with your webpack config file. +WARNING: To supress this warning, please set env USE_APP_WEBPACK_CONFIG to true. +WARNING: `); + config = customConfig; } else { composer.addPartialToProfile("custom", "user", customConfig); } } - if (!config) config = compose(); + if (!config) { + config = compose(); + config[xarcWebpackConfig] = true; + } logger.verbose("Final Webpack config", JSON.stringify(config, null, 2));