Gruntfile.js
2.91 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/**
* 1 :: Combine and uglify all JavaScript sources into 1 minified file.
* Start with (external) libraries that are really needed (dependencies).
*/
uglify: {
build: {
files: {
'js/app.min.js': ['js/libs/*.js', 'js/app.js']
}
}
},
/**
* 2 :: Process SASS (SCSS) files and compile their CSS version.
*/
sass: {
options: {
// app.scss loads components from foundation.
// Without this include, grunt would not know where to get them from.
includePaths: ['bower_components/foundation/scss']
},
dist: {
options: {
// We will minify our final combined CSS file anyway.
outputStyle: 'normal'
},
files: {
'css/app.css': 'scss/app.scss',
}
}
},
/**
* 3 :: Combine different CSS files into 1 file.
* Start with (external) CSS (libs) that are really needed.
*/
concat_css: {
options: {
// Task-specific options go here.
},
all: {
src: ['css/**/*.css', '!css/style*css'],
dest: 'css/style-unprefixed.css'
},
},
/**
* 4 :: If there is CSS3 that needs browser-specific prefixes,
* this library will add these (create the different variants).
* On the contrary, if the original CSS contains prefixes that are no
* longer marked as needed, it will remove them (e.g. border-radius).
*/
autoprefixer: {
global: {
files : {
'css/style.css': 'css/style-unprefixed.css'
}
}
},
/**
* 5 :: Minify the prefixed CSS file to preserve bandwidth.
*/
cssmin: {
build: {
src: 'css/style.css',
dest: 'css/style.min.css'
}
},
/**
* 6 :: Combine all svg files and create one mapped svg sprite we can include.
*/
svgstore: {
options: {
prefix: "shape-",
cleanup: false,
svg: {
style: "display: none;"
}
},
default: {
files: {
'assets/svg-defs.svg': ['svg/*.svg']
}
}
},
/**
* X :: Watch files for changes and act on them (recompile etc...).
*/
watch: {
options: {
livereload: true,
},
grunt: {
files: ['Gruntfile.js']
},
css: {
files: ['scss/**/*.scss', 'css/libs/*.css'],
tasks: ['sass', 'concat_css', 'autoprefixer', 'cssmin']
},
scripts: {
files: ['js/**/*.js', '!js/**/*.min.js'],
tasks: ['uglify']
},
svg: {
files: 'svg/**/*.svg',
tasks: ['svgstore']
}
}
});
// Load necessairy grunt tasks based on npm modules.
require("load-grunt-tasks")(grunt);
grunt.registerTask('build', ['uglify', 'sass', 'concat_css', 'autoprefixer', 'cssmin', 'svgstore']);
grunt.registerTask('default', ['build','watch']);
}