-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
162 lines (147 loc) · 4.4 KB
/
Gruntfile.js
File metadata and controls
162 lines (147 loc) · 4.4 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
module.exports = function(grunt) {
// All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Update Grunt dependencies
devUpdate: {
main: {
options: {
updateType: 'report', //just report outdated packages
reportUpdated: false, //don't report up-to-date packages
semver: true, //stay within semver when updating
packages: {
devDependencies: true, //only check for devDependencies
dependencies: true
},
packageJson: null, //use matchdep default findup to locate package.json
reportOnlyPkgs: [] //use updateType action on all packages
}
}
}
,
// Concatenate all scripts to one file
concat: {
dist: {
src: [
'assets/js/app/*.js', // All JS within app folder (Our JS)
'assets/js/libs/*.js' // JS within libs folder (External scripts we've downloaded)
// 'assets/js/global.js' // If we need to isolate specific file, do that here
],
dest: 'assets/js/build/production.js',
}
}
,
// Use things from Modernizr
modernizr: {
dist: {
devFile: 'assets/js/libs/modernizr.custom.70803.js',
outputFile: 'assets/js/build/custom-modernizr.js',
files: {
src: [
'assets/js/**/*.js',
'assets/css/**/*.css',
]
}
}
}
,
// Minify that script file
uglify: {
build: {
src: 'assets/js/build/production.js',
dest: 'assets/js/build/production.min.js'
}
}
,
// Optimise all image assets
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'assets/img/',
src: ['**/*.{png,jpg,gif}'],
dest: 'assets/img/'
}]
}
}
,
// Auto prefix any CSS3 properties in CSS file
autoprefixer: {
options: {
browsers: ['last 2 versions']
},
dist: { // Target
files: {
'assets/css/screen.css': 'assets/css/screen.css'
}
}
}
,
// Compile Sass
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'assets/css/screen.css': 'assets/sass/screen.scss'
}
}
}
,
// Monitor these files for any changes
watch: {
scripts: {
files: ['assets/js/**/*.js'],
tasks: ['concat', 'uglify'],
options: {
spawn: false,
},
},
css: {
files: ['assets/sass/**/*.scss'],
tasks: ['sass'],
options: {
spawn: false,
}
}
}
});
// Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks("grunt-modernizr");
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-dev-update');
// Run: grunt
grunt.registerTask('default',
[
'sass',
'autoprefixer',
'watch'
]);
// Run: grunt build
grunt.registerTask('build',
[
'concat',
'modernizr',
'uglify',
'sass',
'autoprefixer'
]);
// Run: grunt assets
grunt.registerTask('assets',
[
'uglify',
'imagemin'
]);
// Run: grunt devupdates
grunt.registerTask('devupdates',
[
'devUpdate'
]);
};