forked from PokemonGo-Enhanced/Enhanced-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
140 lines (122 loc) · 4.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* eslint key-spacing:0 spaced-comment:0 */
const path = require('path');
const _debug = require('debug');
const { argv } = require('yargs');
const debug = _debug('app:config');
debug('Creating default configuration.');
// ========================================================
// Default Configuration
// ========================================================
const config = {
env : process.env.NODE_ENV || 'development',
// ----------------------------------
// Project Structure
// ----------------------------------
path_base : path.resolve(__dirname, '..'),
dir_client : 'src',
dir_dist : 'dist',
dir_server : 'server',
dir_test : 'tests',
// ----------------------------------
// Server Configuration
// ----------------------------------
server_host : process.env.HOST || 'localhost',
server_port : process.env.PORT || 3000,
// ----------------------------------
// Compiler Configuration
// ----------------------------------
compiler_css_modules : true,
compiler_devtool : 'source-map',
compiler_hash_type : 'hash',
compiler_fail_on_warning : false,
compiler_quiet : false,
compiler_public_path : '/',
compiler_stats : {
chunks : false,
chunkModules : false,
colors : true
},
compiler_vendor : [
'axios',
'history',
'react',
'react-redux',
'react-router',
'react-router-redux',
'redux',
'radium',
'radium-grid',
'radium-normalize',
'bluebird',
'react-tap-event-plugin',
'sort-by',
'react-waypoint'
],
// ----------------------------------
// Test Configuration
// ----------------------------------
coverage_reporters : [
{ type : 'text-summary' }
]
};
/************************************************
-------------------------------------------------
All Internal Configuration Below
Edit at Your Own Risk
-------------------------------------------------
************************************************/
// ------------------------------------
// Environment
// ------------------------------------
// N.B.: globals added here must _also_ be added to .eslintrc
config.globals = {
'process.env' : {
'NODE_ENV' : JSON.stringify(config.env),
'API_URL' : JSON.stringify(process.env.API_URL || `http://${config.server_host}:${config.server_port}`)
},
'NODE_ENV' : config.env,
'__DEV__' : config.env === 'development',
'__PROD__' : config.env === 'production',
'__TEST__' : config.env === 'test',
'__DEBUG__' : config.env === 'development' && !argv.no_debug,
'__COVERAGE__' : !argv.watch && config.env === 'test',
'__BASENAME__' : JSON.stringify(process.env.BASENAME || '')
};
// ------------------------------------
// Validate Vendor Dependencies
// ------------------------------------
const pkg = require('../package.json');
config.compiler_vendor = config.compiler_vendor
.filter((dep) => {
if (pkg.dependencies[dep] || pkg.devDependencies[dep]) return true;
debug(
`Package "${dep}" was not found as an npm dependency in package.json; ` +
`it won't be included in the webpack vendor bundle.
Consider removing it from vendor_dependencies in ~/config/index.js`
);
});
// ------------------------------------
// Utilities
// ------------------------------------
const resolve = path.resolve;
const base = (...args) =>
Reflect.apply(resolve, null, [config.path_base, ...args]);
config.utils_paths = {
base : base,
client : base.bind(null, config.dir_client),
dist : base.bind(null, config.dir_dist),
assets : base.bind(null, 'assets')
};
// ========================================================
// Environment Configuration
// ========================================================
debug(`Looking for environment overrides for NODE_ENV "${config.env}".`);
const environments = require('./environments');
const overrides = environments[config.env];
if (overrides) {
debug('Found overrides, applying to default configuration.');
Object.assign(config, overrides(config));
} else {
debug('No environment overrides found, defaults will be used.');
}
module.exports = config;