-
Notifications
You must be signed in to change notification settings - Fork 23
/
assign_default_options.js
64 lines (54 loc) · 1.41 KB
/
assign_default_options.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
var assign = require("lodash/assign"),
forEach = require("lodash/forEach"),
logging = require("./logger");
module.exports = function(config, options){
if(options.__defaultsAssigned) {
return options;
}
options = assign({ // Defaults
envify: true,
minify: false,
bundleSteal: false,
uglifyOptions: {},
cleanCSSOptions: {
rebase: false,
inline: ["none"]
},
removeDevelopmentCode: true,
namedDefines: true,
bundlePromisePolyfill: false,
maxBundleRequests: options.maxBundleRequests || options.bundleDepth,
maxMainRequests: options.maxMainRequests || options.mainDepth
}, options);
if(options.sourceMaps) {
assign(config, {
lessOptions: assign({}, options.lessOptions, {
sourceMap: {}
})
});
}
if(options.ignore) {
config.meta = config.meta || {};
forEach(options.ignore, function(value){
config.meta[value] = {
"bundle": false
};
});
}
if(config.bundlesPath) {
throw new Error("bundlesPath has been removed. Use dest instead: http://stealjs.com/docs/steal-tools.BuildOptions.html");
}
// Tree-shaking
if(options.treeShaking === false) {
config.treeShaking = false;
}
// package.json!npm is now the default
if(!config.config && !config.configMain) {
config.configMain = "package.json!npm";
}
// Setup logging
logging.setup(options, config);
// Flag this so that we only run this function once
options.__defaultsAssigned = true;
return options;
};