forked from openshift/origin-web-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
154 lines (146 loc) · 4.41 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
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
module.exports = function (grunt) {
'use strict';
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
function init () {
grunt.initConfig({
availabletasks: {
tasks: {
options: {
descriptions: {
'help': 'Task list helper for your Grunt enabled projects.',
'clean': 'Deletes the content of the dist directory.',
'build': 'Builds the project into the dist directory.',
'test': 'Executes the karma testsuite.',
'watch': 'Automatically rebuild /dist whenever /src files change.'
},
groups: {
'Basic project tasks': ['help', 'clean', 'build', 'test']
}
}
}
},
watch: {
scripts: {
files: ['src/**/*', 'test/**/*.js'],
tasks: ['deploy', 'test'],
options: {
spawn: false,
},
},
},
clean: {
all: ['dist/*']
},
concat: {
options: {
separator: ';'
},
ui: {
src: ['src/**/*UI.module.js', 'dist/scripts/templates.js', 'src/components/**/*.js', 'src/filters/**/*.js', 'src/ui-services/**/*.js'],
dest: 'dist/origin-web-common-ui.js'
},
services: {
src: ['src/**/*Services.module.js', 'src/services/**/*.js', 'src/constants/**/*.js'],
dest: 'dist/origin-web-common-services.js'
},
dist: {
src: ['src/**/*.module.js', 'dist/scripts/templates.js', 'src/**/*.js'],
dest: 'dist/origin-web-common.js'
}
},
copy: {
main: {
files: [
{expand: true, cwd: 'src/styles/', src: ['*'], dest: 'dist/less/'}
]
}
},
karma: {
unit: {
configFile: 'test/karma.conf.js',
singleRun: true
}
},
less: {
production: {
files: {
'dist/origin-web-common.css': 'src/styles/main.less'
},
options: {
cleancss: true,
paths: ['src/styles', 'bower_components/']
}
}
},
htmlmin: {
dist: {
options: {
preserveLineBreaks: true,
collapseWhitespace: true,
conservativeCollapse: false,
collapseBooleanAttributes: false,
removeComments: true,
removeCommentsFromCDATA: true,
removeOptionalTags: false,
keepClosingSlash: true
},
files: [{
expand: true,
src: ['src/components/{,*/}*.html'],
dest: 'dist'
}]
}
}, // ng-annotate tries to make the code safe for minification automatically
// by using the Angular long form for dependency injection.
ngAnnotate: {
dist: {
files: [{
src: 'dist/origin-web-common.js',
dest: 'dist/origin-web-common.js'
}]
}
},
ngtemplates: {
dist: {
src: 'src/components/**/*.html',
dest: 'dist/scripts/templates.js',
options: {
module: 'openshiftCommonUI',
standalone: false,
htmlmin: ''
}
}
},
uglify: {
options: {
compress: {},
mangle: false,
beautify: {
beautify: true,
indent_level: 0,
space_colon: false, // Don't waste characters
width: 1000
}
},
build: {
files: {},
src: 'dist/origin-web-common.js',
dest: 'dist/origin-web-common.min.js'
}
}
});
// You can specify which modules to build as arguments of the build task.
grunt.registerTask('build', 'Create bootstrap build files', function () {
grunt.task.run(['clean', 'ngtemplates', 'concat', 'copy', 'ngAnnotate', 'less', 'uglify:build', 'test']);
});
// Runs all the tasks of build with the exception of tests
grunt.registerTask('deploy', 'Prepares the project for deployment. Does not run unit tests', function () {
grunt.task.run(['clean', 'ngtemplates', 'concat', 'copy', 'ngAnnotate', 'less', 'uglify:build']);
});
grunt.registerTask('default', ['build']);
grunt.registerTask('test', ['karma']);
grunt.registerTask('check', ['test']);
grunt.registerTask('help', ['availabletasks']);
}
init({});
};