This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·73 lines (70 loc) · 1.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
module.exports = function(grunt) {
grunt.initConfig({
// Read Package Information
pkg: grunt.file.readJSON('package.json'),
// Generate File Banner
banner: '/*! \n' +
'* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +
'*/\n',
// Lint Javascript
jshint: {
all: {
src: ['browser-update.js'],
},
gruntfile: {
src: ['Gruntfile.js'],
}
},
uglify: {
options: {
mangle: false,
},
files: {
src: 'browser-update.js',
dest: './', // source files mask
expand: true, // allow dynamic building
flatten: true, // remove all unnecessary nesting
ext: '.min.js' // replace .js to .min.js
},
main: {
options: {
banner: '<%= banner %>'
},
files: {
'browser-update.min.js': ['browser-update.js']
}
},
},
// Watch for Changes
watch: {
// Live lint new scripts
scripts: {
files: ['assets/js/*.js'],
tasks: ['jshint', 'concat', 'uglify'],
options: {
spawn: false,
// Start a live reload server
livereload: true,
},
},
// Live lint Grunt file
gruntfile: {
files: 'Gruntfile.js',
tasks: ['jshint:gruntfile', 'uglify'],
},
},
});
// Load Grunt Modules //
// Watch
grunt.loadNpmTasks('grunt-contrib-watch');
// Lint JS
grunt.loadNpmTasks('grunt-contrib-jshint');
// Uglify JS
grunt.loadNpmTasks('grunt-contrib-uglify');
// Runt Grunt Tasks //
grunt.registerTask('default', ['jshint','uglify', 'watch']);
grunt.registerTask('test', ['jshint']);
};