This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
forked from dash1291/commonplace
/
config.js
167 lines (157 loc) · 4.7 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
var CORE_MODULES = [
// Core JS modules.
// Will tell Gulp which modules to pull into marketplace-core-modules/.
// Will tell the require.js config which files live in marketplace-core-modules/.
'assert',
'buckets',
'builder',
'cache',
'capabilities',
'defer',
'forms',
'format',
'helpers',
'l10n',
'log',
'login',
'models',
'navigation',
'notification',
'nunjucks',
'nunjucks.compat',
'polyfill',
'requests',
'site_config',
'storage',
'urls',
'user',
'utils',
'views',
'z'
];
var CORE_MODULES_ROOT_JS = [
// Core modules that traditionally live in the root JS path.
'l10n',
'views'
];
var CORE_VIEWS = [
'views/fxa_authorize',
'views/not_found',
'views/tests'
];
var BASE_TEMPLATES = [
'server.html'
];
var BASE_PATH = 'src/media/';
var CORE_SRC_PATH = 'marketplace-core-modules/';
var CORE_TEMPLATE_PATH = 'commonplace/dist/core-templates/';
var JS_DEST_PATH = BASE_PATH + 'js/';
var LIB_DEST_PATH = JS_DEST_PATH + 'lib/';
var CORE_DEST_PATH = LIB_DEST_PATH + 'marketplace-core-modules/';
var CSS_DEST_PATH = BASE_PATH + 'css/';
// Build config object to tell Gulp which Bower files into project and where.
var bowerConfig = {
'almond/almond.js': LIB_DEST_PATH,
'jquery/jquery.js': LIB_DEST_PATH,
// TODO: Use the official nunjucks and not a modified one.
// 'nunjucks/browser/nunjucks-slim.js': LIB_DEST_PATH,
'underscore/underscore.js': LIB_DEST_PATH,
'commonplace/dist/core-templates/tests.html': 'src/templates/commonplace/',
'marketplace-core-modules/tests/**/*.js': CORE_DEST_PATH + 'tests'
};
CORE_MODULES.forEach(function(module) {
if (CORE_MODULES_ROOT_JS.indexOf(module) !== -1) {
// Modules that go into the root JS path (for some reason).
bowerConfig[CORE_SRC_PATH + module + '.js'] = JS_DEST_PATH;
return;
}
bowerConfig[CORE_SRC_PATH + module + '.js'] = CORE_DEST_PATH;
});
CORE_VIEWS.forEach(function(view) {
bowerConfig[CORE_SRC_PATH + view + '.js'] = CORE_DEST_PATH + 'views/';
});
BASE_TEMPLATES.forEach(function(template) {
bowerConfig[CORE_TEMPLATE_PATH + template] = 'src/';
});
// Build require config, to be used in development and AMD optimizers.
var requireConfig = {
enforceDefine: true,
paths: {
'jquery': 'lib/jquery',
// 'nunjucks': 'lib/nunjucks-slim',
'templates': '../../templates',
'underscore': 'lib/underscore',
'views/not_found': 'lib/marketplace-core-modules/views/not_found',
'views/tests': 'lib/marketplace-core-modules/views/tests',
},
shim: {
'underscore': {
'exports': '_'
},
}
};
CORE_MODULES.forEach(function(module) {
if (CORE_MODULES_ROOT_JS.indexOf(module) !== -1) {
return;
}
requireConfig.paths[module] = 'lib/marketplace-core-modules/' + module;
});
CORE_VIEWS.forEach(function(view) {
requireConfig.paths[view] = 'lib/marketplace-core-modules/' + view;
});
var BOWER_PATH = process.env.BOWER_PATH || './bower_components/';
// Server config to allow easy switching of servers in settings.
var serverConfig = {
prod: {
api_url: 'https://marketplace.firefox.com',
media_url: 'https://marketplace.cdn.mozilla.net/media/',
},
dev: {
api_url: 'https://marketplace-dev.allizom.org',
media_url: 'https://marketplace-dev.mozflare.net/media/',
},
stage: {
api_url: 'https://marketplace.allizom.org',
media_url: 'https://marketplace-stage.cdn.mozilla.net/media/',
},
altdev: {
api_url: 'https://marketplace-altdev.allizom.org',
media_url: 'https://marketplace-altdev-cdn.allizom.org/media/',
},
paymentsalt: {
api_url: 'https://payments-alt.allizom.org',
media_url: 'https://payments-alt-cdn.allizom.org/media/',
},
localhost: {
api_url: 'http://localhost',
media_url: 'http://localhost',
},
mpdev: {
api_url: 'http://mp.dev',
media_url: 'http://mp.dev/media/',
},
mock: {
api_url: 'https://flue.paas.allizom.org',
media_url: 'https://flue.paas.allizom.org',
},
mocklocal: {
api_url: 'http://localhost:5000',
media_url: 'http://localhost:5000',
},
};
module.exports = {
bowerConfig: bowerConfig,
requireConfig: requireConfig,
serverConfig: serverConfig,
BOWER_PATH: BOWER_PATH,
CSS_DEST_PATH: CSS_DEST_PATH,
JS_DEST_PATH: JS_DEST_PATH,
LIB_DEST_PATH: LIB_DEST_PATH,
makeInlineRequireConfig: function(requireConfig) {
return '(function() {' +
'require.config(' +
JSON.stringify(requireConfig) +
');' +
'}())';
}
};