-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
executable file
Β·256 lines (242 loc) Β· 10.2 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
var path = require('path');
var NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-pug');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
/* ---------------------
ARCHIVED YEARS
--------------------*/
// grunt.loadNpmTasks('grunt-css-mqpacker');
// grunt.loadNpmTasks('grunt-postcss-import');
grunt.initConfig({
stylus: {
compile: {
options: {
/* ---------------------------------------------------
ARCHIVE NOTE:
This is required to compile 2021 and earlier,
but will error for 2022 and later.
To compile those files, please comment accordingly.
---------------------------------------------------*/
// use: [
// require('autoprefixer-stylus')
// ]
},
files: {
'public/assets/css/main.css': ['_styl/main.styl'],
'public/assets/css/monokai-sublime.css': ['_styl/components/code-monokai.styl'],
'public/assets/css/code.css': ['_styl/components/code-panda.styl']
/* ---------------------------------------------------
ARCHIVE NOTE:
These generated CSS files are in assets/css/archive
The following do not need autoprefixer
---------------------------------------------------*/
// 'public/assets/css/archive/2022.css': ['_styl/archive/2022.styl'],
/* ---------------------------------------------------
ARCHIVE NOTE:
These generated CSS files are in assets/css/archive
To compile these, you will need autoprefixer above
---------------------------------------------------*/
// 'public/assets/css/archive/2021.css': ['_styl/archive/2021.styl'],
// 'public/assets/css/archive/2020.css': ['_styl/archive/2020.styl'],
// 'public/assets/css/archive/2019-home.css': ['_styl/archive/2019/pages/home.styl'],
// 'public/assets/css/archive/2019.css': ['_styl/archive/2019.styl'],
// '_css/archive/2018/generated-post.css': ['_styl/archive/2018/pages/home/_post.styl'],
// '_css/archive/2018/generated-home-base.css': ['_styl/archive/2018/pages/home/base.styl'],
// '_css/archive/2018/generated-home-small.css': ['_styl/archive/2018/pages/home/view-small.styl'],
// '_css/archive/2018/generated-home-large.css': ['_styl/archive/2018/pages/home/view-large.styl'],
// 'public/assets/css/archive/2018.css': ['_styl/archive/2018.styl'],
// 'public/assets/css/archive/2017.css': ['_styl/archive/2017.styl'],
// 'public/assets/css/archive/2017-home.css': ['_styl/archive/2017/pages/home.styl'],
// 'public/assets/css/archive/2016.css': ['_styl/archive/2016.styl'],
// 'public/assets/css/archive/2015.css': ['_styl/archive/2015.styl'],
// 'public/assets/css/archive/2015-ie.css': ['_styl/archive/2015/sections/ie.styl'],
// 'public/assets/css/archive/2014.css': ['_styl/archive/2014.styl'],
// 'public/assets/css/archive/2013.css': ['_styl/archive/2013.styl'],
// 'public/assets/css/archive/2012.css': ['_styl/archive/2012.styl'],
// 'public/assets/css/archive/2011.css': ['_styl/archive/2011.styl'],
// 'public/assets/css/archive/2010.css': ['_styl/archive/2010.styl' ],
// 'public/assets/css/archive/2009.css': ['_styl/archive/2009.styl'],
// 'public/assets/css/archive/2008.css': ['_styl/archive/2008.styl'],
// 'public/assets/css/archive/2007.css': ['_styl/archive/2007.styl']
}
}
},
/* ---------------------
ARCHIVED YEARS
---------------------*/
// css_mqpacker: {
// public: {
// files: [{
// '_css/archive/2018/generated-home-small.css': ['_css/archive/2018/generated-home-small.css'],
// '_css/archive/2018/generated-home-large.css': ['_css/archive/2018/generated-home-large.css']
// }]
// }
// },
// postcss_import: {
// public: {
// files: [{
// 'public/assets/css/archive/2018-home.css': ['_css/archive/2018/generated-post.css']
// }]
// }
// },
cssmin: {
target: {
files: [{
expand: true,
cwd: 'public/assets/css',
src: ['home.css', 'main.css', 'monokai-sublime.css', 'archive/*.css', '!*.min.css'],
dest: 'public/assets/css',
ext: '.css',
}]
}
},
pug: {
basic: {
files: [{
expand: true,
cwd: '_pug',
src: ['**/*.pug'],
dest: 'public',
ext: '.html',
'public/404.html': ['_pug/404.pug'],
//Don't render pug files in include or with a _ in the front
filter: function (src) {
if (src.indexOf('include') > -1) {
return false;
}
if (path.basename(src)[0] === '_') {
return false;
}
return true;
},
//Move non index.html files into their own dir for clean paths
rename: function (dest, src) {
if (src !== 'index.html' && src !== '404.html') {
return dest + '/' + src.replace('.html', '/index.html');
}
return dest + '/' + src;
}
}]
}
},
//- browserify the main javascript file to the output js dir
browserify: {
main: {
src: '_js/main.js',
dest: 'public/js/main.js',
}
},
//- minify any js files in the output dir
uglify: {
target: {
files: [{
expand: true,
cwd: 'public/js',
src: ['*.js', '!*.min.js'],
dest: 'public/js',
ext: '.min.js'
}]
}
},
copy: {
public: {
files: [
{
cwd: '_assets',
expand: true,
src: ['**'],
dest: 'public/assets'
},
{
cwd: '_blog-assets',
expand: true,
src: ['**'],
dest: 'public/images/blog'
},
{
cwd: '_rss',
expand: true,
src: ['**'],
dest: 'public/'
},
{
src: ['_redirects'],
dest: 'public/'
},
{
src: ['robots.txt'],
dest: 'public/'
}
]
},
},
watch: {
pug: {
files: ['_pug/**'],
tasks: ['pug:basic'],
options: {
spawn: false,
livereload: true
}
},
css: {
files: ['_styl/**'],
tasks: ['css'],
options: {
livereload: true
}
},
js: {
files: ['_js/**'],
tasks: ['js'],
options: {
livereload: true
}
},
assets: {
files: ['_assets/**'],
tasks: ['copy'],
options: {
livereload: true
}
}
},
connect: {
server: {
options: {
port: 9001,
base: 'public',
livereload: true,
open: true
}
}
},
clean: ['public']
});
grunt.event.on('watch', (action, filepath, target) => {
if (target === 'pug') {
const files = grunt.config('pug.basic.files');
files[0].cwd = '_pug';
files[0].src = ['**/*.pug'];
grunt.config.set('pug.basic.files', files);
}
});
/* ---------------------
ARCHIVED YEARS
---------------------*/
// grunt.registerTask('css', ['stylus', 'css_mqpacker', 'postcss_import', 'cssmin']);
// Note: cssmin breaks the :has supports stuff, so leaving off for now
grunt.registerTask('css', ['stylus']);
grunt.registerTask('js', ['browserify', 'uglify']);
grunt.registerTask('build', ['clean', 'css', 'js', 'pug', 'copy']);
grunt.registerTask('serve', ['build', 'connect:server', 'watch']);
grunt.registerTask('default', ['build']);
};