This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
index.js
103 lines (87 loc) · 2.67 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
process.env.NODE_ENV = (process.env.NODE_ENV || 'development').trim();
import path from 'path';
import { argv } from 'yargs';
const config = new Map();
// ------------------------------------
// User Configuration
// ------------------------------------
// NOTE: Due to limitations with Webpack's custom require, which is used for
// looking up all *.spec.js files, if you edit dir_src you _must_ also edit
// the path in ~/karma.entry.js.
config.set('dir_src', 'src');
config.set('dir_dist', 'dist');
config.set('server_host', 'localhost');
config.set('server_port', process.env.PORT || 4000);
config.set('webpack_port', 3000);
config.set('vendor_dependencies', [
'history',
'immutable',
'react',
'react-redux',
'react-router',
'redux',
'redux-devtools',
'redux-devtools/lib/react'
]);
config.set('webpack_lint_in_dev', true);
/* *********************************************
-------------------------------------------------
All Internal Configuration Below
Edit at your own risk
-------------------------------------------------
************************************************/
// ------------------------------------
// Environment
// ------------------------------------
config.set('env', process.env.NODE_ENV);
config.set('globals', {
'process.env' : {
'NODE_ENV' : JSON.stringify(config.get('env'))
},
'NODE_ENV' : config.get('env'),
'__DEV__' : config.get('env') === 'development',
'__PROD__' : config.get('env') === 'production',
'__DEBUG__' : config.get('env') === 'development' && !argv.no_debug,
'__DEBUG_NW__' : !!argv.nw
});
// ------------------------------------
// Webpack
// ------------------------------------
config.set('webpack_public_path',
`http://${config.get('server_host')}:${config.get('webpack_port')}/`
);
// ------------------------------------
// Project
// ------------------------------------
config.set('path_project', path.resolve(__dirname, '../'));
// ------------------------------------
// Utilities
// ------------------------------------
const paths = (() => {
const base = [config.get('path_project')],
resolve = path.resolve;
const project = (...args) => resolve.apply(resolve, [...base, ...args]);
return {
project : project,
src : project.bind(null, config.get('dir_src')),
dist : project.bind(null, config.get('dir_dist'))
};
})();
config.set('utils_paths', paths);
config.set('utils_aliases', [
'actions',
'components',
'constants',
'containers',
'dispatchers',
'layouts',
'models',
'reducers',
'routes',
'services',
'stores',
'styles',
'utils',
'views'
].reduce((acc, x) => ((acc[x] = paths.src(x)) && acc), {}));
export default config;