defaulted to Prod

master
hsarma 5 years ago
parent 92b7aa619f
commit b7a540f4ea

@ -1,27 +1,27 @@
/* eslint key-spacing:0 spaced-comment:0 */ /* eslint key-spacing:0 spaced-comment:0 */
import path from 'path' import path from "path";
import _debug from 'debug' import _debug from "debug";
import { argv } from 'yargs' import { argv } from "yargs";
import ip from 'ip' import ip from "ip";
const localip = ip.address() const localip = ip.address();
const debug = _debug('app:config') const debug = _debug("app:config");
debug('Creating default configuration.') debug("Creating default configuration.");
// ======================================================== // ========================================================
// Default Configuration // Default Configuration
// ======================================================== // ========================================================
const config = { const config = {
env : process.env.NODE_ENV || 'development', env: process.env.NODE_ENV || "production",
// ---------------------------------- // ----------------------------------
// Project Structure // Project Structure
// ---------------------------------- // ----------------------------------
path_base : path.resolve(__dirname, '..'), path_base: path.resolve(__dirname, ".."),
dir_client : 'src', dir_client: "src",
dir_dist : 'dist', dir_dist: "dist",
dir_server : 'server', dir_server: "server",
dir_test : 'tests', dir_test: "tests",
// ---------------------------------- // ----------------------------------
// Server Configuration // Server Configuration
@ -33,34 +33,34 @@ const config = {
// Compiler Configuration // Compiler Configuration
// ---------------------------------- // ----------------------------------
compiler_css_modules: true, compiler_css_modules: true,
compiler_devtool : 'source-map', compiler_devtool: "source-map",
compiler_hash_type : 'hash', compiler_hash_type: "hash",
compiler_fail_on_warning: false, compiler_fail_on_warning: false,
compiler_quiet: false, compiler_quiet: false,
compiler_public_path : '/', compiler_public_path: "/",
compiler_stats: { compiler_stats: {
chunks: false, chunks: false,
chunkModules: false, chunkModules: false,
colors : true colors: true,
}, },
compiler_vendor: [ compiler_vendor: [
'babel-polyfill', "babel-polyfill",
'history', "history",
'react', "react",
'react-redux', "react-redux",
'react-router', "react-router",
'react-router-redux', "react-router-redux",
'redux' "redux",
], ],
// ---------------------------------- // ----------------------------------
// Test Configuration // Test Configuration
// ---------------------------------- // ----------------------------------
coverage_reporters: [ coverage_reporters: [
{ type : 'text-summary' }, { type: "text-summary" },
{ type : 'lcov', dir : 'coverage' } { type: "lcov", dir: "coverage" },
] ],
} };
/************************************************ /************************************************
------------------------------------------------- -------------------------------------------------
@ -76,58 +76,57 @@ Edit at Your Own Risk
// ------------------------------------ // ------------------------------------
// N.B.: globals added here must _also_ be added to .eslintrc // N.B.: globals added here must _also_ be added to .eslintrc
config.globals = { config.globals = {
'process.env' : { "process.env": {
'NODE_ENV' : JSON.stringify(config.env) NODE_ENV: JSON.stringify(config.env),
}, },
'NODE_ENV' : config.env, NODE_ENV: config.env,
'__DEV__' : config.env === 'development', __DEV__: config.env === "development",
'__PROD__' : config.env === 'production', __PROD__: config.env === "production",
'__TEST__' : config.env === 'test', __TEST__: config.env === "test",
'__DEBUG__' : config.env === 'development' && !argv.no_debug, __DEBUG__: config.env === "development" && !argv.no_debug,
'__COVERAGE__' : !argv.watch && config.env === 'test', __COVERAGE__: !argv.watch && config.env === "test",
'__BASENAME__' : JSON.stringify(process.env.BASENAME || '') __BASENAME__: JSON.stringify(process.env.BASENAME || ""),
} };
// ------------------------------------ // ------------------------------------
// Validate Vendor Dependencies // Validate Vendor Dependencies
// ------------------------------------ // ------------------------------------
const pkg = require('../package.json') const pkg = require("../package.json");
config.compiler_vendor = config.compiler_vendor config.compiler_vendor = config.compiler_vendor.filter((dep) => {
.filter((dep) => { if (pkg.dependencies[dep]) return true;
if (pkg.dependencies[dep]) return true
debug( debug(
`Package "${dep}" was not found as an npm dependency in package.json; ` + `Package "${dep}" was not found as an npm dependency in package.json; ` +
`it won't be included in the webpack vendor bundle. `it won't be included in the webpack vendor bundle.
Consider removing it from vendor_dependencies in ~/config/index.js` Consider removing it from vendor_dependencies in ~/config/index.js`
) );
}) });
// ------------------------------------ // ------------------------------------
// Utilities // Utilities
// ------------------------------------ // ------------------------------------
const resolve = path.resolve const resolve = path.resolve;
const base = (...args) => const base = (...args) =>
Reflect.apply(resolve, null, [config.path_base, ...args]) Reflect.apply(resolve, null, [config.path_base, ...args]);
config.utils_paths = { config.utils_paths = {
base: base, base: base,
client: base.bind(null, config.dir_client), client: base.bind(null, config.dir_client),
dist : base.bind(null, config.dir_dist) dist: base.bind(null, config.dir_dist),
} };
// ======================================================== // ========================================================
// Environment Configuration // Environment Configuration
// ======================================================== // ========================================================
debug(`Looking for environment overrides for NODE_ENV "${config.env}".`) debug(`Looking for environment overrides for NODE_ENV "${config.env}".`);
const environments = require('./environments').default const environments = require("./environments").default;
const overrides = environments[config.env] const overrides = environments[config.env];
if (overrides) { if (overrides) {
debug('Found overrides, applying to default configuration.') debug("Found overrides, applying to default configuration.");
Object.assign(config, overrides(config)) Object.assign(config, overrides(config));
} else { } else {
debug('No environment overrides found, defaults will be used.') debug("No environment overrides found, defaults will be used.");
} }
export default config export default config;

Loading…
Cancel
Save