Skip to content

Commit

Permalink
archetype-react-app: [patch] log loading custom webpack config (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Jun 19, 2017
1 parent da5e945 commit 62b1903
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
"use strict";

const xsh = require("xsh");
const partialConfigs = require("../partial");
const WebpackConfigComposer = require("webpack-config-composer");
const optionalRequire = require("optional-require")(require);
const Path = require("path");
const _ = require("lodash");
const logger = require("electrode-archetype-react-app/lib/logger");

/* eslint-disable max-statements */
function generateConfig(options) {
const composer = new WebpackConfigComposer();
composer.addProfiles(options.profiles);
composer.addPartials(partialConfigs.partials);

const customConfig =
optionalRequire(Path.resolve(options.configFilename)) ||
optionalRequire(Path.resolve("archetype/config/webpack", options.configFilename));
let customConfig;
const customDirs = [process.cwd(), Path.resolve("archetype/config/webpack")];

const foundDir = customDirs.find(d => {
customConfig = optionalRequire(Path.join(d, options.configFilename));
return !!customConfig;
});
if (foundDir) {
const dir = xsh.pathCwd.replace(foundDir);
logger.info(`Custom webpack config ${options.configFilename} loaded from ${dir}`);
} else {
const dirs = customDirs.map(d => xsh.pathCwd.replace(d)).join("; ");
logger.info(`No custom webpack config ${options.configFilename} found in dirs ${dirs}`);
}

const keepCustomProps = options.keepCustomProps;
const compose = () => composer.compose({ keepCustomProps }, options.profileNames);
Expand Down
3 changes: 2 additions & 1 deletion packages/electrode-archetype-react-app-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"webpack-dev-server": "^2.2.0",
"webpack-disk-plugin": "0.0.2",
"webpack-stats-plugin": "^0.1.1",
"winston": "^2.3.1"
"winston": "^2.3.1",
"xsh": "^0.3.2"
},
"optionalDependencies": {
"electrode-archetype-opt-inferno": "^0.1.0",
Expand Down

0 comments on commit 62b1903

Please sign in to comment.