-
Notifications
You must be signed in to change notification settings - Fork 2
/
gruntfile.js
173 lines (150 loc) · 5.11 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
165
166
167
168
169
170
171
172
173
module.exports = function(grunt) {
require('time-grunt')(grunt);
var devmode = grunt.option('dev');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['build/css','build/js','build/inc'],
sass: {
options: {
implementation: require('node-sass'),
sourceMap: true
},
dist: {
files: {
'build/css/unprefixed/style-unprefixed.css': 'src/assets/sass/main.scss',
'build/css/unprefixed/backlink-unprefixed.css': 'src/assets/sass/backlink.scss'
}
}
},
postcss: {
options: {
map: {
inline: false, // save all sourcemaps as separate files...
// annotation: 'assets/css/maps/' // ...to the specified directory
},
processors: [
require('autoprefixer')(),
require('cssnano')(),
]
},
dist: {
expand: true,
flatten: true,
files: {
// note the difference between `source` and `src`, the latter `src` folder and the `build` folder are not copied over to `dist`
'source/assets/css/main.css': 'build/css/unprefixed/style-unprefixed.css',
'source/assets/css/backlink.css': 'build/css/unprefixed/backlink-unprefixed.css',
}
}
},
copy: {
main: {
files: {
'source/_includes/detect-webfont.js.inc': 'build/js/detect-webfont.min.js',
'source/_includes/responsive-nav.js.inc': 'build/js/responsive-nav.min.js',
'source/_includes/backlink.js.inc': 'build/js/backlink.min.js',
'source/_includes/backlink.css.inc': 'source/assets/css/backlink.css'
},
flatten: true,
filter: 'isFile',
},
},
concat: {
dist: {
files: {
'build/js/detect-webfont.js': ['src/assets/js/feature-detect.js','src/assets/js/webfontloader.js'],
}
}
},
uglify: {
options: {
// livereload: true,
// preserveComments: 'false'
preserveComments: /^!/
// only preserve comments that start with a bang
// https://github.com/gruntjs/grunt-contrib-uglify/issues/366
},
dist: {
files: {
'build/js/detect-webfont.min.js': 'build/js/detect-webfont.js',
'build/js/responsive-nav.min.js': 'src/assets/js/responsive-nav.js',
'build/js/backlink.min.js': 'src/assets/js/backlink.js',
}
}
},
svgstore: {
options: {
svg: { // will add and overide the the default xmlns="http://www.w3.org/2000/svg" attribute to the resulting SVG
viewBox : '0 0 32 32',
xmlns: 'http://www.w3.org/2000/svg'
}
},
default: {
files: {
'source/_includes/svgstore.twig': ['src/assets/img/icons/*.svg'],
},
},
},
watch: {
options: {
// using the LiveReload browser-extension here, see https://github.com/gruntjs/grunt-contrib-watch#live-reloading
livereload: 35729,
},
scss: {
files: ['src/assets/sass/**/*.scss'],
tasks: ['scss','postcss','copy'],
options: {
// spawn: false
}
},
js: {
files: ['src/assets/js/**/*.js'],
tasks: ['concat','uglify', 'copy'],
options: {
// spawn: false
}
},
},
exec: {
remove_ds_store1: {
command: 'rm -f *.DS_Store',
stdout: false,
stderr: false
},
remove_ds_store2: {
command: 'rm -f source/.DS_Store',
stdout: false,
stderr: false
},
remove_ds_store3: {
command: 'rm -f source/_posts/.DS_Store',
stdout: false,
stderr: false
},
remove_ds_store4: {
command: 'rm -f source/_includes/.DS_Store',
stdout: false,
stderr: false
},
remove_ds_store5: {
command: 'rm -f source/_views/.DS_Store',
stdout: false,
stderr: false
}
},
});
grunt.registerTask('build', ['clean','concat','uglify','sass','postcss:dist','copy','svgstore']);
grunt.registerTask('clean', ['clean']);
grunt.registerTask('scss', ['sass', 'postcss:dist']);
grunt.registerTask('js', ['uglify', 'concat']);
grunt.registerTask('default', ['build', 'watch']);
grunt.registerTask('dev', ['watch']);
grunt.loadNpmTasks('grunt-sass','grunt-contrib-concat','grunt-contrib-uglify','grunt-contrib-watch','matchdep','grunt-postcss','grunt-contrib-copy','grunt-contrib-clean','grunt-svgstore','grunt-exec');
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Default tasks to be run.
};
// if (devmode) {
// grunt.task.registerTask('hashres', function(){ console.log('Skipping hashres task because of --dev flag'); });
// grunt.task.registerTask('uncss', function(){ console.log('Skipping uncss task because of --dev flag'); });
// }
// };