forked from dirkgroenen/viewport-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
99 lines (88 loc) · 3.06 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
module.exports = function(grunt){
/**
* Load required Grunt tasks. These are all installed when running `npm install`.
*/
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
/**
* This is the configuration object Grunt uses to give each
* plugin its instructions
*/
var taskConfig = {
/**
* Read the package.json file so we can access the package name and
* version.
*/
pkg: grunt.file.readJSON("package.json"),
/**
* The banner is the comment that is placed at the top of our compiled
* source files. It is first processed as a Grunt template, where the `<%=`
* pairs are evaluated based on this very configuration object.
*/
meta: {
banner:
'/**\n' +
' * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.homepage %>\n' +
' *\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed <%= pkg.licenses.type %> <<%= pkg.licenses.url %>>\n' +
' */\n'
},
/**
* Minify all javascript sources
*/
uglify: {
compile: {
options: {
sourceMap: true,
banner: '<%= meta.banner %>'
},
files: {
'dist/jquery.viewportchecker.min.js': 'src/jquery.viewportchecker.js'
}
}
},
/**
* Start watching for file changes to speed up the development process
*/
delta: {
options: {
livereload: true
},
/**
* When our JavaScript source files change, we want to run lint them and
* run our unit tests.
*/
jssrc: {
files: [
'src/jquery.viewportchecker.js'
],
tasks: [ 'jshint:src' ]
},
},
/**
* Validate the Javascript src file which is located in src directory
*/
jshint: {
src: [
'src/jquery.viewportchecker.js'
],
}
};
grunt.initConfig(taskConfig);
/**
* In order to make it safe to just compile or copy *only* what was changed,
* we need to ensure we are starting from a clean, fresh build. So we rename
* the `watch` task to `delta` (that's why the configuration var above is
* `delta`) and then add a new task called `watch` that does a check
* before watching for changes.
*/
grunt.renameTask( 'watch', 'delta' );
grunt.registerTask( 'watch', [ 'jshint:src', 'delta' ] );
/**
* Task which will minify the source and place it in the distribute directory
*/
grunt.registerTask( 'compile', [ 'jshint:src', 'uglify:compile' ] );
}