-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
86 lines (80 loc) · 2.68 KB
/
Gruntfile.js
File metadata and controls
86 lines (80 loc) · 2.68 KB
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
'use strict';
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-lesslint');
grunt.loadNpmTasks('grunt-contrib-connect');
//Using exclusion patterns slows down Grunt significantly
//instead of creating a set of patterns like '**/*.js' and '!**/node_modules/**'
//this method is used to create a set of inclusive patterns for all subdirectories
//skipping node_modules, bower_components, dist, and any .dirs
//This enables users to create any directory structure they desire.
var createFolderGlobs = function (fileTypePatterns) {
fileTypePatterns = Array.isArray(fileTypePatterns) ? fileTypePatterns : [fileTypePatterns];
var ignore = ['node_modules', 'bower_components', 'dist', 'temp'];
var fs = require('fs');
return fs.readdirSync(process.cwd())
.map(function (file) {
if (ignore.indexOf(file) !== -1 ||
file.indexOf('.') === 0 ||
!fs.lstatSync(file).isDirectory()) {
return null;
} else {
return fileTypePatterns.map(function (pattern) {
return file + '/**/' + pattern;
});
}
})
.filter(function (patterns) {
return patterns;
})
.concat(fileTypePatterns);
};
// Project configuration.
grunt.initConfig({
watch: {
options: {
livereload: true,
atBegin: true
},
less: {
files: [createFolderGlobs(['*.less'])],
tasks: ['less'],
options: {
livereload: false
}
},
html: {
files: [createFolderGlobs('*.html')],
tasks: []
},
css: {
files: [createFolderGlobs('*.css'), 'temp/app.css'],
tasks: []
}
},
less: {
production: {
options: {
sourceMap: true,
outputSourceFiles: true,
sourceMapURL: '/temp/bootstrap-ext.css.map'
},
files: {
'temp/bootstrap-ext.css': 'less/bootstrap-ext.less'
}
}
},
connect: {
demo: {
options: {
port: 9001,
open: 'http://localhost:9001/demo/index.html'
}
}
}
});
grunt.registerTask('fewer', ['less']);
grunt.registerTask('build', ['less']);
grunt.registerTask('serve',['connect','watch']);
};