Skip to content

Commit

Permalink
detect Electrode webpack config generated by user and use directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Feb 20, 2020
1 parent 544100d commit 71a0335
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/xarc-app-dev/config/webpack/util/generate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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`<yellow>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));

Expand Down

0 comments on commit 71a0335

Please sign in to comment.