This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
85 lines (66 loc) · 2.06 KB
/
config.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
/**************************************
Warning: In this file use only ES5!
**************************************/
var path = require('path');
var argv = require('yargs').argv;
var config = new Map();
// ----------------------
// User Configuration
// ----------------------
config.set('dir_src', 'src');
config.set('dir_dist', 'public');
config.set('webpack_host', 'localhost');
config.set('webpack_port', 3000);
config.set('api_uri', 'http://localhost:8080/mock-api/'); // Simple change address to your full api url
/**************************************
All Internal Configuration Below
Edit at Your Own Risk
**************************************/
// ----------------------
// Environment
// ----------------------
config.set('env', process.env.NODE_ENV);
config.set('globals', {
'process.env' : {
'NODE_ENV' : config.get('env')
},
'NODE_ENV' : config.get('env'),
'__DEV__' : config.get('env') === 'development',
'__PROD__' : config.get('env') === 'production',
'__API_URI__' : argv.api_uri || config.get('api_uri')
});
// ----------------------
// Webpack
// ----------------------
config.set('webpack_public_path',
'http://' + config.get('webpack_host') + ':' + config.get('webpack_port') + '/'
);
// ----------------------
// Babel
// ----------------------
config.set('babel_options', {
babelrc: false,
presets: ['es2015', 'stage-0', 'react']
});
// ----------------------
// Project
// ----------------------
config.set('path_project', path.resolve(__dirname, '.'));
// ----------------------
// Utilities
// ----------------------
var paths = (function() {
var base = [config.get('path_project')];
var resolve = path.resolve;
var project = function() {
var args = Array.prototype.slice.call(arguments);
return resolve.apply(resolve, base.concat(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);
module.exports = config;