-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
149 lines (130 loc) · 3.45 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
module.exports = function(grunt) {
'use strict';
// Force use of Unix newlines
grunt.util.linefeed = '\n';
RegExp.quote = function(string) {
return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
};
var fs = require('fs');
var path = require('path');
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
// Task configuration.
clean: {
dist: ['client/css', 'client/js']
},
concat: {
sliqsolv: {
src: ['js/addons/**/*.js'],
dest: 'client/js/<%= pkg.name %>.js'
},
app: {
src: ['js/app/**/*.js'],
dest: 'client/js/app.js'
}
},
uglify: {
options: {
preserveComments: 'some'
},
vendor: {
src: [
'node_modules/jquery/dist/jquery.js', 'node_modules/angular/angular.js',
'node_modules/angular-animate/angular-animate.js', 'node_modules/angular-route/angular-route.js',
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js', 'node_modules/packery/dist/packery.pkgd.min.js'
],
dest: 'client/js/vendor.min.js'
}
},
less: {
compileCore: {
options: {
strictMath: true
},
src: ['less/bootstrap.less', 'less/addons/sliqsolv.less'],
dest: 'client/css/<%= pkg.name %>.css'
}
},
autoprefixer: {
core: {
options: {
map: false
},
src: 'client/css/<%= pkg.name %>.css'
}
},
csslint: {
options: {
csslintrc: 'less/.csslintrc'
},
dist: 'client/css/<%= pkg.name %>.css'
},
cssmin: {
options: {
compatibility: 'ie8',
keepSpecialComments: '*',
noAdvanced: true
},
minifyCore: {
src: 'client/css/<%= pkg.name %>.css',
dest: 'client/css/<%= pkg.name %>.min.css'
}
},
csscomb: {
options: {
config: 'less/.csscomb.json'
},
dist: {
expand: true,
cwd: 'client/css/',
src: ['*.css', '!*.min.css'],
dest: 'client/css/'
}
},
copy: {
css: {/* src: 'css/*', dest: 'dist/' */},
js: {/* src: 'js/*', dest: 'dist/' */},
html: {/* expand: true, cwd: 'client/', src: '** /*.html', dest: 'dist/' */},
fonts: {/* src: 'fonts/*', dest: 'dist/' */}
},
watch: {
src: {
files: 'js/**/*.js',
tasks: ['concat']
},
/* html: { files: 'client/** /*.html', tasks: 'copy:html' }, */
less: {
files: 'less/**/*.less',
tasks: 'less'
}
},
sed: {
versionNumber: {
pattern: (function() {
var old = grunt.option('oldver');
return old ? RegExp.quote(old) : old;
})(),
replacement: grunt.option('newver'),
recursive: true
}
},
exec: {
npmUpdate: {
command: 'npm update'
}
}
});
// These plugins provide necessary tasks.
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
// JS distribution task.
grunt.registerTask('dist-js', ['concat', 'uglify']);
// CSS distribution task.
grunt.registerTask('less-compile', ['less:compileCore']);
grunt.registerTask('dist-css', ['less-compile', 'autoprefixer:core', 'csscomb:dist', 'cssmin:minifyCore']);
// Full distribution task.
grunt.registerTask('dist', ['clean:dist', 'dist-css', 'dist-js']);
// Default task.
grunt.registerTask('default', ['clean:dist', 'dist']);
};