-
Notifications
You must be signed in to change notification settings - Fork 80
/
gruntfile.js
124 lines (107 loc) · 3.18 KB
/
gruntfile.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
/* eslint-disable global-require, no-param-reassign,
no-useless-concat, import/no-extraneous-dependencies */
module.exports = function (grunt) {
grunt.file.defaultEncoding = 'utf-8';
grunt.file.preserveBOM = true;
const sass = require('./build/configs/sass.js');
const chokidar = require('./build/configs/watch.js');
const amdHeader = require('./build/configs/amdHeader.js');
const copy = require('./build/configs/copy.js');
const cssmin = require('./build/configs/cssmin.js');
const usebanner = require('./build/configs/usebanner.js');
const compress = require('./build/configs/compress.js');
const meta = require('./build/configs/meta.js');
const clean = require('./build/configs/clean.js');
const dependencyBuilder = require('./build/dependencybuilder.js');
const strBanner = require('./build/strbanner.js');
const controls = require('./build/controls.js');
const run = require('./build/configs/run.js');
let selectedControls = dependencyBuilder(grunt);
let bannerText = '/**\n* Soho XI Controls v<%= pkg.version %>\n* Date: <%= grunt.template.today("dd/mm/yyyy h:MM:ss TT") %>\n* Revision: <%= meta.revision %>\n* <%= meta.copyright %>\n*/\n';
if (selectedControls) {
const bannerList = strBanner(selectedControls);
bannerText = `/**\n* Soho XI Controls v<%= pkg.version %>\n* ${bannerList}\n* Date: <%= grunt.template.today("dd/mm/yyyy h:MM:ss TT") %>\n* Revision: <%= meta.revision %>\n* <%= meta.copyright %>\n*/ \n`;
} else {
selectedControls = controls;
}
const config = {
pkg: grunt.file.readJSON('package.json'),
banner: bannerText,
exec: {
build: {
cmd: 'npm run build'
},
documentation: {
cmd: (componentName) => {
componentName = componentName || '';
return `npm run documentation ${componentName}`;
}
},
minify: {
cmd: 'npm run minify'
}
},
};
// Build out the Grunt config object
grunt.initConfig(Object.assign(
{},
config,
chokidar,
clean,
sass,
meta,
amdHeader,
copy,
cssmin,
usebanner,
compress,
run
));
// load all grunt tasks from 'node_modules' matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
// Default Task:
// - Cleans up
// - Builds
// - Updates local documentation
// - Zips
grunt.registerTask('default', [
'clean:dist',
'build',
'compress',
'exec:documentation'
]);
// Main build task (Gets everything)
grunt.registerTask('build', [
'build:js:min',
'build:sass'
]);
// Javascript Build Tasks
// The first one doesn't minify (expensive, time-wise)
grunt.registerTask('build:js', [
'exec:build',
'copy:main'
]);
grunt.registerTask('build:js:min', [
'exec:build',
'exec:minify',
'copy:main'
]);
// SASS/CSS Build Task
grunt.registerTask('build:sass', [
'sass',
'cssmin',
'usebanner'
]);
// Publish for NPM
grunt.registerTask('publish', [
'default',
'clean:publish',
'copy:publish'
]);
// Watch Task
grunt.registerTask('watch', [
'chokidar'
]);
};
/* eslint-enable global-require, no-param-reassign,
no-useless-concat, import/no-extraneous-dependencies */