This repository has been archived by the owner on Aug 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
124 lines (111 loc) · 3.33 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
// our wrapper function (required by grunt and its plugins)
module.exports = function(grunt) {
// CONFIGURE GRUNT
grunt.initConfig({
// get the configuration info from package.json
pkg: grunt.file.readJSON('package.json'),
// configure plugin with information, sample here is jshint, which doesn't like my code
jshint: {
options: {
reporter: require('jshint-stylish'),
'-W033': true, // mising semicolon
'-W041': true, // use 'x' to compare with 'y'
'-W004': true, // x already in use
'-W014': true // bad line breaking before '||'
},
all: ['Grunfile.js', 'NSF/WebContent/js/*.js']
},
// configure uglify to minify js files -------------------------------------
uglify: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},
build: {
files: {
'public/dist/scripts_via_grunt.min.js': 'NSF/WebContent/js/*.js'
}
}
},
// configure cssmin to minify css files ------------------------------------
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},
build: {
files: {
'dist/css/styles_from_grunt.min.css': 'NSF/WebContent/css/*.css'
}
}
},
// configure htmlmin to remove comments and whitespace or more for dev vs dist
htmlmin: {
build: {
options: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true
},
files: [{
expand: true,
cwd: 'NSF/WebContent/partials',
src: '{,*/}*.html',
dest: 'NSF/WebContent/dist/views'
}]
}
},
// configure watch to auto update ------------------------------------------
watch: {
stylesheets: {
files: ['NSF/WebContent/css/*.css'],
tasks: ['cssmin']
},
scripts: {
files: 'NSF/WebContent/js/*.js',
tasks: ['jshint', 'uglify']
},
partials: {
files: 'NSF/WebContent/partials/*.html',
tasks: ['htmlmin']
}
},
/*
run: {
options: {
// Task-specific options go here.
},
serve: {
exec: 'json-server --id unid db.json --watch --routes routes.json'
}
},
*/
browserSync: {
dev: {
bsFiles: {
src : [
'NSF/WebContent/css/*.css',
'NSF/WebContent/js/*.js',
'NSF/WebContent/partials/*.html'
]
},
options: {
watchTask: true,
proxy: 'localhost:3000'
}
}
}
});
// LOAD GRUNT PLUGINS
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
//grunt.loadNpmTasks('grunt-run');
// CREATE TASKS
grunt.registerTask('default', ['jshint','uglify','cssmin','htmlmin','browserSync','watch']);
};