-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
164 lines (138 loc) · 3.58 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
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
163
164
module.exports = function (grunt) {
'use strict';
// ====================
// == Edit this section
var jsFileList = [
'public/js/socket.io.js',
'public/js/underscore-min.js',
'public/js/script.js'
];
var distDir = 'public/js/dist/';
var jsFile = 'script.min.js';
var cssFile = 'kickoff';
// ====================
// ====================
// Load some stuff
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
pkg: require('./package'),
jshint: {
all: jsFileList,
options: {
jshintrc: '.jshintrc'
}
},
/**
* Sass compilation using grunt-sass
* https://github.com/gruntjs/grunt-contrib-sass
* Includes kickoff.scss and kickoff-old-ie.scss by default
* Also creates source maps
*/
sass: {
kickoff: {
options: {
unixNewlines: true,
style: 'expanded',
lineNumbers: false,
debugInfo : false,
precision : 8,
sourcemap: true
},
files: {
'public/css/temp/kickoff.css' : 'public/scss/kickoff.scss',
'public/css/temp/kickoff-old-ie.css': 'public/scss/kickoff-old-ie.scss'
}
}
},
/**
* Autoprefixer
* https://github.com/nDmitry/grunt-autoprefixer
* https://github.com/ai/autoprefixer
* Auto prefixes your CSS using caniuse data
*/
autoprefixer: {
options: {
// We are supporting the last 2 browsers, any browsers with >1% market share,
// and ensuring we support IE8+ with prefixes
browsers: ['> 5%', 'last 4 versions', 'firefox > 3.6', 'ie > 7'],
map: true
},
kickoff: {
expand: true,
flatten: true,
src: 'public/css/temp/*.css',
dest: 'public/css/'
}
},
/**
* CSSO
* https://github.com/t32k/grunt-csso
* Minify CSS files with CSSO
*/
csso: {
dist: {
options: {
restructure: false //turns structural optimisations off as can mess up fallbacks http://bem.info/tools/optimizers/csso/description/
},
files: {
'public/css/kickoff.css' : 'public/css/kickoff.css',
'public/css/kickoff-old-ie.css': 'public/css/kickoff-old-ie.css'
},
}
},
uglify: {
options: {
// mangle: Turn on or off mangling
mangle: true,
// beautify: beautify your code for debugging/troubleshooting purposes
beautify: false,
// report: Show file size report
report: 'gzip',
// sourceMap: @string. The location of the source map, relative to the project
sourceMap: distDir + jsFile + '.map',
// sourceMappingURL: @string. The string that is printed to the final file
sourceMappingURL: jsFile +'.map',
// sourceMapRoot: @string. The location where your source files can be found. This sets the sourceRoot field in the source map.
sourceMapRoot: '../../'
// sourceMapPrefix: @integer. The number of directories to drop from the path prefix when declaring files in the source map.
// sourceMapPrefix: 1,
},
js: {
src: jsFileList,
dest: distDir + jsFile
}
},
watch: {
scss: {
files: ['public/scss/**/*.scss'],
tasks: [
'sass:kickoff',
'autoprefixer:kickoff'
]
},
js: {
files: [
'Gruntfile.js',
'public/js/**/*.js',
'public/js/libs/**/*.js'
],
tasks: ['uglify']
},
livereload: {
options: { livereload: true },
files: [
'public/css/*.css'
]
}
}
});
// =============
// === Tasks ===
// =============
// A task for development
// A task for deployment
grunt.registerTask('deploy', ['uglify', 'sass:kickoff', 'autoprefixer:kickoff']);
// Default task
grunt.registerTask('default', ['uglify', 'sass:kickoff', 'autoprefixer:kickoff']);
};