1 |
|
2 | var pageBuilder = require('./tests/pages/_script/page-builder');
|
3 |
|
4 | module.exports = function (grunt) {
|
5 | 'use strict';
|
6 |
|
7 |
|
8 | var projectConfig = {
|
9 | dist: 'dist',
|
10 | src: ''
|
11 | };
|
12 |
|
13 |
|
14 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
15 |
|
16 | try {
|
17 | projectConfig.src = require('./bower.json').appPath || projectConfig.src;
|
18 | } catch (e) {}
|
19 |
|
20 | grunt.initConfig({
|
21 | config: projectConfig,
|
22 | connect: {
|
23 | server: {
|
24 | options: {
|
25 | hostname: '0.0.0.0',
|
26 | livereload: true,
|
27 | base: [
|
28 | projectConfig.src,
|
29 | projectConfig.dist + '/tests'
|
30 | ],
|
31 | port: 9000
|
32 | }
|
33 | }
|
34 | },
|
35 | run: {
|
36 | options: {
|
37 | },
|
38 | bundleInstall: {
|
39 | cmd: 'bundle',
|
40 | args: [
|
41 | 'install'
|
42 | ]
|
43 | }
|
44 | },
|
45 | clean: {
|
46 | build: '<%= config.dist %>'
|
47 | },
|
48 | concat: {
|
49 | js: {
|
50 | files: {
|
51 | 'dist/js/patternfly-settings.js': [
|
52 | 'src/js/patternfly-settings-base.js',
|
53 | 'src/js/patternfly-settings-colors.js',
|
54 | 'src/js/patternfly-settings-charts.js'
|
55 | ],
|
56 | 'dist/js/patternfly-functions.js': [
|
57 | 'src/js/patternfly-functions-base.js',
|
58 | 'src/js/patternfly-functions-list.js',
|
59 | 'src/js/patternfly-functions-sidebar.js',
|
60 | 'src/js/patternfly-functions-popovers.js',
|
61 | 'src/js/patternfly-functions-data-tables.js',
|
62 | 'src/js/patternfly-functions-navigation.js',
|
63 | 'src/js/patternfly-functions-count-chars.js',
|
64 | 'src/js/patternfly-functions-colors.js',
|
65 | 'src/js/patternfly-functions-charts.js',
|
66 | 'src/js/patternfly-functions-fixed-heights.js',
|
67 | 'src/js/patternfly-functions-tree-grid.js',
|
68 | 'src/js/patternfly-functions-vertical-nav.js'
|
69 | ],
|
70 | 'dist/js/patternfly.js': [
|
71 | 'dist/js/patternfly-settings.js',
|
72 | 'dist/js/patternfly-functions.js'
|
73 | ]
|
74 | }
|
75 | }
|
76 | },
|
77 | copy: {
|
78 | main: {
|
79 | files: [
|
80 |
|
81 | {expand: true, cwd: 'node_modules/bootstrap/dist/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
82 |
|
83 | {expand: true, cwd: 'node_modules/font-awesome/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
84 |
|
85 | {expand: true, cwd: 'src/less/', src: ['*'], dest: 'dist/less/'},
|
86 |
|
87 | {expand: true, cwd: 'src/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
88 |
|
89 | {expand: true, cwd: 'src/img/', src: ['**'], dest: 'dist/img/'},
|
90 |
|
91 |
|
92 | {expand: true, cwd: 'node_modules/bootstrap/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap/'},
|
93 |
|
94 | {expand: true, cwd: 'node_modules/font-awesome/less/', src: ['**'], dest: 'dist/less/dependencies/font-awesome/'},
|
95 |
|
96 | {expand: true, cwd: 'node_modules/patternfly-bootstrap-combobox/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-combobox/'},
|
97 |
|
98 | {expand: true, cwd: 'node_modules/bootstrap-datepicker/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-datepicker/'},
|
99 |
|
100 | {expand: true, cwd: 'node_modules/bootstrap-select/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-select/'},
|
101 |
|
102 |
|
103 |
|
104 | {expand: true, cwd: 'node_modules/bootstrap-touchspin/dist/', src: ['jquery.bootstrap-touchspin.css'], dest: 'dist/less/dependencies/bootstrap-touchspin/'},
|
105 |
|
106 | {expand: true, cwd: 'node_modules/c3/', src: ['c3.css'], dest: 'dist/less/dependencies/c3/'}
|
107 | ]
|
108 | },
|
109 | js: {
|
110 | files: [
|
111 |
|
112 | {expand: true, cwd: 'src/js/', src: ['*.js'], dest: 'dist/js/'}
|
113 | ]
|
114 | }
|
115 | },
|
116 | csscount: {
|
117 | production: {
|
118 | src: [
|
119 | 'dist/css/patternfly*.min.css'
|
120 | ],
|
121 | options: {
|
122 | maxSelectors: 4096
|
123 | }
|
124 | }
|
125 | },
|
126 | jekyll: {
|
127 | options: {
|
128 | src: 'tests/pages',
|
129 | bundleExec: 'true'
|
130 | },
|
131 | tests: {
|
132 | options: {
|
133 | dest: 'dist/tests'
|
134 | }
|
135 | }
|
136 | },
|
137 | cssmin: {
|
138 | production: {
|
139 | files: [{
|
140 | expand: true,
|
141 | cwd: 'dist/css',
|
142 | src: ['patternfly*.css', '!*.min.css'],
|
143 | dest: 'dist/css',
|
144 | ext: '.min.css',
|
145 | }],
|
146 | options: {
|
147 | sourceMap: true
|
148 | }
|
149 | }
|
150 | },
|
151 | less: {
|
152 | patternfly: {
|
153 | files: {
|
154 | 'dist/css/patternfly.css': 'src/less/patternfly.less',
|
155 | },
|
156 | options: {
|
157 | paths: [
|
158 | 'src/less/',
|
159 | 'node_modules/'
|
160 | ],
|
161 | strictMath: true,
|
162 | sourceMap: true,
|
163 | outputSourceFiles: true,
|
164 | sourceMapFilename: 'dist/css/patternfly.css.map',
|
165 | sourceMapURL: 'patternfly.css.map'
|
166 | }
|
167 | },
|
168 | patternflyAdditions: {
|
169 | files: {
|
170 | 'dist/css/patternfly-additions.css': 'src/less/patternfly-additions.less'
|
171 | },
|
172 | options: {
|
173 | paths: [
|
174 | 'src/less/',
|
175 | 'node_modules/'
|
176 | ],
|
177 | strictMath: true,
|
178 | sourceMap: true,
|
179 | outputSourceFiles: true,
|
180 | sourceMapFilename: 'dist/css/patternfly-additions.css.map',
|
181 | sourceMapURL: 'patternfly-additions.css.map'
|
182 | }
|
183 | }
|
184 | },
|
185 | uglify: {
|
186 | options: {
|
187 | mangle: false
|
188 | },
|
189 | production: {
|
190 | files: {
|
191 | 'dist/js/patternfly.min.js': ['dist/js/patternfly.js'],
|
192 | 'dist/js/patternfly-settings.min.js': ['dist/js/patternfly-settings.js'],
|
193 | 'dist/js/patternfly-functions.min.js': ['dist/js/patternfly-functions.js'],
|
194 | 'dist/js/patternfly.dataTables.pfEmpty.min.js': ['src/js/patternfly.dataTables.pfEmpty.js'],
|
195 | 'dist/js/patternfly.dataTables.pfFilter.min.js': ['src/js/patternfly.dataTables.pfFilter.js'],
|
196 | 'dist/js/patternfly.dataTables.pfPagination.min.js': ['src/js/patternfly.dataTables.pfPagination.js'],
|
197 | 'dist/js/patternfly.dataTables.pfResize.min.js': ['src/js/patternfly.dataTables.pfResize.js'],
|
198 | 'dist/js/patternfly.dataTables.pfSelect.min.js': ['src/js/patternfly.dataTables.pfSelect.js']
|
199 | }
|
200 | }
|
201 | },
|
202 | watch: {
|
203 | copy: {
|
204 | files: [
|
205 | 'node_modules/bootstrap/dist/fonts/**/*',
|
206 | 'node_modules/font-awesome/fonts/**/*',
|
207 | 'src/fonts/**/*',
|
208 | 'src/img/**/*'
|
209 | ],
|
210 | tasks: ['copy']
|
211 | },
|
212 | jekyll: {
|
213 | files: 'tests/pages/**/*',
|
214 | tasks: ['pages']
|
215 | },
|
216 | less: {
|
217 | files: ['src/less/*.less'],
|
218 | tasks: ['less']
|
219 | },
|
220 | css: {
|
221 | files: ['dist/css/patternfly*.css', 'dist/css/!*.min.css'],
|
222 | tasks: ['cssmin','csscount']
|
223 | },
|
224 | js: {
|
225 | files: ['src/js/*.js'],
|
226 | tasks: ['eslint', 'concat', 'copy:js', 'uglify']
|
227 | },
|
228 | livereload: {
|
229 | files: ['dist/css/*.css', 'dist/js/*.js', 'dist/tests/*.html', '!tests/pages/*.html']
|
230 | },
|
231 | options: {
|
232 | livereload: true
|
233 | }
|
234 | },
|
235 | karma: {
|
236 | unit: {
|
237 | configFile: 'karma.conf.js'
|
238 | }
|
239 | },
|
240 | htmlhint: {
|
241 | html: {
|
242 | src: ['dist/tests/**/*.html'],
|
243 | options: {
|
244 | htmlhintrc: '.htmlhintrc'
|
245 | }
|
246 | }
|
247 | },
|
248 | eslint: {
|
249 | options: {
|
250 | configFile: 'eslint.yaml'
|
251 | },
|
252 | target: [
|
253 | 'Gruntfile.js',
|
254 | 'src/js/**/*.js',
|
255 | 'tests/pages/_script/**/*.js'
|
256 | ]
|
257 | },
|
258 | stylelint: {
|
259 | src: ['src/less/*.less']
|
260 | },
|
261 | postcss: {
|
262 | options: {
|
263 | processors: [
|
264 | require('pixrem')(),
|
265 | require('autoprefixer')({browsers: ['last 3 versions', 'ie 9']})
|
266 | ]
|
267 | },
|
268 | dist: {
|
269 | files: [
|
270 | {
|
271 | expand: true,
|
272 | cwd: 'dist/css/',
|
273 | src: ['*.css'],
|
274 | dest: 'dist/css'
|
275 | }
|
276 | ]
|
277 | }
|
278 |
|
279 | }
|
280 | });
|
281 |
|
282 | grunt.registerTask('pages', 'Builds the PatternFly test pages.', function (_target) {
|
283 | var target = _target || process.env.PF_PAGE_BUILDER || 'script';
|
284 | var done;
|
285 | if (target === 'jekyll') {
|
286 | grunt.log.writeln('Builidng test pages with ruby jekyll');
|
287 | grunt.task.run('run:bundleInstall', 'jekyll');
|
288 | } else if (target === 'script') {
|
289 | grunt.log.writeln('Builidng test pages with liquid.js');
|
290 | done = this.async();
|
291 | pageBuilder.build()
|
292 | .then(function () {
|
293 | done();
|
294 | });
|
295 | } else {
|
296 | grunt.log.writeln('Invalid taget:', target);
|
297 | }
|
298 | });
|
299 |
|
300 | grunt.registerTask('build', [
|
301 | 'clean',
|
302 | 'concat',
|
303 | 'copy',
|
304 | 'pages',
|
305 | 'less',
|
306 | 'cssmin',
|
307 | 'postcss',
|
308 | 'csscount',
|
309 | 'eslint',
|
310 | 'uglify',
|
311 | 'htmlhint',
|
312 | 'stylelint'
|
313 | ]);
|
314 |
|
315 | grunt.registerTask('serve', [
|
316 | 'connect:server',
|
317 | 'watch'
|
318 | ]);
|
319 |
|
320 | grunt.registerTask('server', function () {
|
321 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
|
322 | grunt.task.run(['serve']);
|
323 | });
|
324 |
|
325 | grunt.registerTask('default', ['build']);
|
326 | };
|