forked from frontend-rescue/keep-up-to-date
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
94 lines (76 loc) · 2.24 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
'use strict';
var languages = require('./languages.json');
var moment = require('moment');
module.exports = function(grunt) {
var lang = grunt.option('lang') || 'en',
config = grunt.file.readJSON('config.json');
config.locals.languages = languages;
config.locals.lang = lang;
config.contents = './contents/' + lang;
moment.locale(lang);
config.locals.lastupdate = moment().format('LL');
grunt.file.write('config-' + lang + '.json', JSON.stringify(config));
function moveIndex() {
var file = {'src': 'temp/index.html', 'dest': 'build/index.html'}
if (lang !== 'en') {
file.dest = 'build/' + lang + '/index.html';
}
return file;
}
// Project configuration.
grunt.initConfig({
'pkg': grunt.file.readJSON('package.json'),
'wintersmith_compile': {
'build': {
'options': {
'config': './config-' + lang + '.json',
'output': './temp/'
}
}
},
'cssmin': {
'options': {
'keepSpecialComments': 0
},
'css': {
'src': ['src/css/normalize.css', 'src/css/base.css', 'src/css/how.css'],
'dest': 'build/src/css/styles.min.css'
},
'uri': {
'src': ['src/css/data-uri.css'],
'dest': 'build/src/css/data-uri.css'
}
},
'copy': {
'assets': {
'files': [
{'src': ['src/assets/no-image.png'], 'dest': 'build/'},
{'src': ['src/assets/favicon.ico'], 'dest': 'build/favicon.ico'}
]
},
'index': {
'files': [moveIndex()]
}
},
'htmlmin': {
'dist': {
'options': {
'collapseWhitespace': true
},
'files': [
{ 'expand': true, 'cwd': 'build/', 'src': ['**/*.html'], 'dest': 'build/' }
]
}
},
'clean': ['config-' + lang + '.json', './temp']
});
// Load plugins
grunt.loadNpmTasks('grunt-wintersmith-compile');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
// Resgister task(s).
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['wintersmith_compile', 'cssmin', 'htmlmin', 'copy', 'clean']);
};