Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
dev condition and configuration support
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed May 11, 2016
1 parent bf0028c commit 88b4b28
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Builder.prototype.reset = function(baseLoader) {
loader.pluginLoader.config(cfg);
var lCfg = extend({}, cfg);
// build environment is not production or the browser, but will follow nodeConfig, because the build is in Node
lCfg.browserConfig = lCfg.productionConfig = undefined;
lCfg.browserConfig = lCfg.productionConfig = lCfg.devConfig = undefined;
loaderConfig.call(this, lCfg);
loader.configHash = generateConfigHash(loader);
};
Expand Down Expand Up @@ -338,7 +338,7 @@ function processTraceOpts(options, defaults) {
browser: undefined,
node: undefined,
production: undefined,
development: undefined,
dev: undefined,
traceAllConditionals: true,
conditions: {},
traceConditionsOnly: false,
Expand All @@ -354,7 +354,7 @@ function processTraceOpts(options, defaults) {
};

// ensure user environment overrides default environment
if (options) {
if (typeof options == 'object') {
if (typeof options.browser == 'boolean' || typeof options.node == 'boolean') {
// browser true/false -> node is opposite
if (typeof options.browser == 'boolean' && typeof options.node != 'boolean')
Expand All @@ -364,11 +364,14 @@ function processTraceOpts(options, defaults) {
options.browser = !options.node;
}

if (typeof options.development == 'boolean' || typeof options.production == 'boolean') {
// development -> dev backwards compat
if ('development' in options)
options.dev = options.development;
if (typeof options.dev == 'boolean' || typeof options.production == 'boolean') {
if (typeof options.production != 'boolean')
options.production = !options.development;
if (typeof options.development != 'boolean')
options.development = !options.production;
options.production = !options.dev;
if (typeof options.dev != 'boolean')
options.dev = !options.production;
}
}

Expand All @@ -389,6 +392,8 @@ function processTraceOpts(options, defaults) {
if (typeof opts.production == 'boolean') {
opts.conditions['@system-env|production'] = opts.production;
opts.conditions['~@system-env|production'] = opts.development;
opts.conditions['@system-env|dev'] = opts.development;
opts.conditions['~@system-env|dev'] = opts.production;
}

return opts;
Expand Down

0 comments on commit 88b4b28

Please sign in to comment.