-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
146 lines (128 loc) · 5.7 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
module.exports = function(grunt){
"use strict";
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
banner: '/*!\n' +
'*@concat.min.css\n' +
'*@CSS Document for Land Use Website @ MAG\n' +
'*@For Production\n' +
'*@<%= pkg.name %> - v<%= pkg.version %> | <%= grunt.template.today("mm-dd-yyyy") %>\n' +
'*@author <%= pkg.author %>\n' +
'*/\n',
htmlhint: {
build: {
options: {
"tag-pair": true, // Force tags to have a closing pair
"tagname-lowercase": true, // Force tags to be lowercase
"tag-self-close": true, // The empty tag must closed by self
"attr-lowercase": true, // Force attribute names to be lowercase e.g. <div id="header"> is invalid
"attr-value-double-quotes": true, // Force attributes to have double quotes rather than single
"attr-value-not-empty": true, // Attribute must set value
"doctype-first": true, // Force the DOCTYPE declaration to come first in the document
"spec-char-escape": true, // Force special characters to be escaped
"id-unique": true, // Prevent using the same ID multiple times in a document
// "head-script-disabled": false, // Prevent script tags being loaded in the head for performance reasons
"style-disabled": true, // Prevent style tags. CSS should be loaded through
"src-not-empty": true, // src of img(script,link) must set value
"img-alt-require": true, // Alt of img tag must be set value
"csslint": true, // Scan css with csslint
"jshint": true, // Scan script with jshint
"force": false // Report HTMLHint errors but don't fail the task
},
src: ["index.html"]
}
},
// CSSLint. Tests CSS code quality
// https://github.com/gruntjs/grunt-contrib-csslint
csslint: {
// define the files to lint
files: ["css/main.css"],
strict: {
options: {
"import": 0,
"empty-rules": 0,
"display-property-grouping": 0,
"shorthand": 0,
"font-sizes": 0,
"zero-units": 0,
"important": 0,
"duplicate-properties": 0,
}
}
},
jshint: {
files: ["js/main.js"],
options: {
// strict: true,
sub: true,
quotmark: "double",
trailing: true,
curly: true,
eqeqeq: true,
unused: true,
scripturl: true, // This option defines globals exposed by the Dojo Toolkit.
dojo: true, // This option defines globals exposed by the jQuery JavaScript library.
jquery: true, // Set force to true to report JSHint errors but not fail the task.
force: true,
reporter: require("jshint-stylish-ex")
}
},
uglify: {
options: {
// add banner to top of output file
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> | <%= grunt.template.today("mm-dd-yyyy") %> */\n',
// mangle: false,
// compress: true,
},
build: {
files: {
"js/main.min.js": ["js/main.js"],
}
}
},
cssmin: {
add_banner: {
options: {
// add banner to top of output file
banner: '/* <%= pkg.name %> - v<%= pkg.version %> | <%= grunt.template.today("mm-dd-yyyy") %> */\n'
},
files: {
"css/main.min.css": ["css/main.css"],
"css/normalize.min.css": ["css/normalize.css"],
"css/bootstrapmap.min.css": ["css/bootstrapmap.css"]
}
}
},
concat: {
options: {
stripBanners: true,
banner: '<%= banner %>'
},
dist: {
src: ["css/normalize.min.css", "css/bootstrapmap.min.css", "css/main.min.css"],
dest: 'app/resources/css/concat.min.css'
}
},
watch: {
scripts: {
files: ["js/main.js", "Gruntfile.js"],
tasks: ["jshint"],
options: {
spawn: false,
interrupt: true,
},
},
},
});
// this would be run by typing "grunt test" on the command line
grunt.registerTask("work", ["jshint"]);
grunt.registerTask("buildcss", ["cssmin", "concat"]);
grunt.registerTask("buildjs", ["uglify"]);
// the default task can be run just by typing "grunt" on the command line
grunt.registerTask("default", []);
};
// ref
// http://coding.smashingmagazine.com/2013/10/29/get-up-running-grunt/
// http://csslint.net/about.html
// http://www.jshint.com/docs/options/