forked from longbill/jquery-date-range-picker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBrocfile.js
114 lines (108 loc) · 2.73 KB
/
Brocfile.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
'use strict'
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');
const Sass = require('broccoli-sass');
const Browserify = require('broccolify');
const UglifyJS = require('broccoli-uglify-sourcemap');
const TranspileJs = require('broccoli-babel-transpiler');
const buildConfig = {
// Uncomment locales from this list which you do not want to include in
// your build
disabledLocales: [
//'az',
//'zh-cn',
//'cs',
//'de',
//'en',
//'es',
//'fr',
//'hu',
//'it',
//'no',
//'nl',
//'pl',
//'ru',
//'se'
],
// Uncomment features to be disabled in your custom build
disabledFeatures: [
//'all',
//'daytime-selection-controls', // 2.4kb
//'shortcuts', // 3kb
//'week-numbers', // 1.7kb
//'custom-buttons',
//'directional-selection',
//'mousewheel-month-scroll',
//'days-tooltip', // 1.9kb
//'jquery-plugin'
]
}
const buildConfigCore = {
disabledLocales: [
'az',
'cn',
'cz',
'de',
//'en',
'es',
'fr',
'hu',
'it',
'no',
'nl',
'pl',
'ru',
'se'
],
disabledFeatures: [
'all',
'jquery-plugin'
]
}
const makeJsTree = config => {
const disabledLocales = [];
const disabledFeatures = [];
for (let i = 0; i < config.disabledLocales.length; ++i) {
disabledLocales.push('./lib/locales/' + config.disabledLocales[i] + '.js');
}
const featureModuleMap = {
'all': './lib/plugins.js',
'daytime-selection-controls': './lib/plugins/daytime-selection.js',
'shortcuts': './lib/plugins/shortcuts.js',
'week-numbers': './lib/plugins/week-numbers.js',
'days-tooltip': './lib/day-tooltip.js',
'jquery-plugin': './lib/plugins/jquery-plugin.js',
'custom-buttons': './lib/plugins/custom-buttons.js',
'directional-selection': './lib/plugins/directional-selection.js',
'mousewheel-month-scroll': './lib/plugins/mousewheel-month-scroll.js'
};
for (let i = 0; i < config.disabledFeatures.length; ++i) {
disabledFeatures.push(featureModuleMap[config.disabledFeatures[i]]);
}
return Browserify('lib', {
entries: ['./main.js'],
outputFile: 'jquery.daterangepicker.js',
ignore: ['jquery', 'moment'].concat(disabledLocales).concat(disabledFeatures),
bundle: {
//standalone: 'daterangepicker'
}
});
}
const makeTree = () => {
const css = new Sass(['sass'], 'styles.scss', 'daterangepicker.css');
let js = makeJsTree(buildConfig);
js = TranspileJs(js);
// copy jquery.daterangepicker.js to put it through uglify
let minJs = Funnel(js, {
include: ['*'],
getDestinationPath: (path) => {
if (path === 'jquery.daterangepicker.js') {
return 'jquery.daterangepicker.min.js';
}
return path;
}
});
minJs = UglifyJS(minJs);
return new MergeTrees([js, minJs, css]);
}
module.exports = makeTree();