Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use process.env as a proper object. #565

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified dist/server/build.js
100644 → 100755
Empty file.
18 changes: 10 additions & 8 deletions dist/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
});
exports.nodePaths = exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined;

var _keys = require('babel-runtime/core-js/object/keys');

var _keys2 = _interopRequireDefault(_keys);

var _stringify = require('babel-runtime/core-js/json/stringify');

var _stringify2 = _interopRequireDefault(_stringify);

var _keys = require('babel-runtime/core-js/object/keys');

var _keys2 = _interopRequireDefault(_keys);

exports.loadEnv = loadEnv;

var _webpack = require('webpack');
Expand Down Expand Up @@ -47,20 +47,22 @@ function loadEnv() {

var defaultNodeEnv = options.production ? 'production' : 'development';
var env = {
'process.env.NODE_ENV': (0, _stringify2.default)(process.env.NODE_ENV || defaultNodeEnv),
'NODE_ENV': process.env.NODE_ENV || defaultNodeEnv,
// This is to support CRA's public folder feature.
// In production we set this to dot(.) to allow the browser to access these assests
// even when deployed inside a subpath. (like in GitHub pages)
// In development this is just empty as we always serves from the root.
'process.env.PUBLIC_URL': (0, _stringify2.default)(options.production ? '.' : '')
'PUBLIC_URL': options.production ? '.' : ''
};

(0, _keys2.default)(process.env).filter(function (name) {
return (/^STORYBOOK_/.test(name)
);
}).forEach(function (name) {
env['process.env.' + name] = (0, _stringify2.default)(process.env[name]);
env[name] = process.env[name];
});

return env;
return {
'process.env': (0, _stringify2.default)(env)
};
}
10 changes: 6 additions & 4 deletions src/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ export const nodePaths = (process.env.NODE_PATH || '')
export function loadEnv(options = {}) {
const defaultNodeEnv = options.production ? 'production' : 'development';
const env = {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || defaultNodeEnv),
'NODE_ENV': process.env.NODE_ENV || defaultNodeEnv,
// This is to support CRA's public folder feature.
// In production we set this to dot(.) to allow the browser to access these assests
// even when deployed inside a subpath. (like in GitHub pages)
// In development this is just empty as we always serves from the root.
'process.env.PUBLIC_URL': JSON.stringify(options.production ? '.' : ''),
'PUBLIC_URL': options.production ? '.' : '',
};

Object.keys(process.env)
.filter(name => /^STORYBOOK_/.test(name))
.forEach((name) => {
env[`process.env.${name}`] = JSON.stringify(process.env[name]);
env[name] = process.env[name];
});

return env;
return {
'process.env': JSON.stringify(env),
};
}