Repository navigation
Expand file tree
/
Copy pathGruntfile.js
More file actions
106 lines (102 loc) · 2.59 KB
/
Copy pathGruntfile.js
File metadata and controls
106 lines (102 loc) · 2.59 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// linting JS
jshint: {
files: [
'Gruntfile.js',
'assets/scripts/*.js'
]
},
// minifying JS
uglify: {
options: {
report: 'min'
//banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
all: {
files: [
{
expand: true, // Enable dynamic expansion.
cwd: 'assets/scripts/', // Src matches are relative to this path.
src: ['*.js'], // Actual pattern(s) to match.
dest: 'assets/scripts/min/', // Destination path prefix.
ext: '.js' // Dest filepaths will have this extension.
}
]
}
},
// compiling CSS
compass: {
all: {
options: {
outputStyle: 'compressed',
httpPath: '/',
cssDir: 'assets/styles/min',
sassDir: 'assets/styles',
imagesDir: 'assets/images',
javascriptsDir: 'assets/scripts'
}
}
},
// compressing images
imagemin: { // Task
all: { // Target
options: { // Target options
optimizationLevel: 3
},
files: [ // Dictionary of files
{
expand: true, // Enable dynamic expansion.
cwd: 'assets/images/', // Src matches are relative to this path.
src: ['*.png'], // Actual pattern(s) to match.
dest: 'assets/images/', // Destination path prefix.
ext: '.png' // Dest filepaths will have this extension.
},
{
expand: true, // Enable dynamic expansion.
cwd: 'assets/images/', // Src matches are relative to this path.
src: ['*.jpg'], // Actual pattern(s) to match.
dest: 'assets/images/', // Destination path prefix.
ext: '.jpg' // Dest filepaths will have this extension.
}
]
}
},
// compare file sizes
compare_size: {
files: [
'assets/**/*.js',
'assets/**/*.scss',
'assets/**/*.css'
]
},
// watch task to automatically generate files during development
watch: {
styles: {
files: 'assets/styles/*.scss',
tasks: ['compass', 'imagemin'],
options: {
interrupt: true
}
},
scripts: {
files: 'assets/scripts/*.js',
tasks: ['jshint', 'uglify'],
options: {
interrupt: true
}
}
}
});
// load the plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-compare-size');
// set tasks
grunt.registerTask('default', ['jshint', 'uglify', 'compass', 'imagemin', 'compare_size']);
};