-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
130 lines (119 loc) · 3.37 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
'use strict';
// Configuring Grunt tasks:
// http://gruntjs.com/configuring-tasks
module.exports = function (grunt) {
// load all grunt tasks matching the `grunt-*` pattern
// https://github.com/sindresorhus/load-grunt-tasks
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Watch for changes and trigger compass, jshint & uglify
watch: {
compass: {
files: ['sass/{,**/}*.scss'],
tasks: ['compass:dev']
},
js: {
files: '<%= jshint.all %>',
tasks: ['newer:jshint', 'uglify:dev']
},
images: {
files: ['src-img/**/*.{png,jpg,gif}'],
tasks: ['newer:imagemin'],
options: {
spawn: false,
}
}
},
// Compass and scss
compass: {
options: {
config: 'config.rb'
},
dev: {
options: {
environment: 'development',
outputStyle: 'expanded',
relativeAssets: true
}
},
prod: {
options: {
environment: 'production',
outputStyle: 'compact',
force: true
}
}
},
// Javascript linting with jshint
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'js/sonambulo.js'
]
},
imagemin: {
options: {
optimizationLevel: 3,
cache: false
},
dist: {
files: [{
// cwd is 'current working directory'
expand: true, // Enable dynamic expansion
cwd: 'src-img/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'img/' // Destination path prefix
}]
}
},
// Concat & minify
uglify: {
dev: {
options: {
mangle: false,
compress: false,
preserveComments: 'all',
beautify: true
},
files: {
'js/sonambulo.min.js': ['js/sonambulo.js']
// Output: input
}
},
prod: {
options: {
mangle: true,
compress: true
},
files: {
'js/sonambulo.min.js': ['js/sonambulo.js']
}
}
}
});
// Load the plugin(s), but I'm using load-grunt-tasks
// https://github.com/sindresorhus/load-grunt-tasks
// grunt.loadNpmTasks('grunt-concurrent');
// Where we tell Grunt what to do when we type "grunt" into the terminal.
// The "default" task is what I leave running all the time. Since it is the default,
// you can start it by simply running
// $ grunt
// or, to run production's tasks
// $ grunt build
grunt.registerTask('build', [
'jshint',
'uglify:prod',
'compass:prod'
]);
grunt.registerTask('default', [
'imagemin',
'newer:jshint',
'uglify:dev',
'compass:dev',
'watch'
]);
};