-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.js
89 lines (78 loc) · 2.13 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
module.exports = function(grunt) {
var AutoPrefixPlugin = require('less-plugin-autoprefix');
var CleanCssPlugin = require('less-plugin-clean-css');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
dev: {
paths: ['static/less/'],
src: ['static/less/raintank.less'],
dest: 'build/dev/css/raintank.css',
options: {
strictMath: true
}
},
dist: {
paths: ['static/less/'],
src: ['static/less/raintank.less'],
dest: 'build/dist/css/raintank.css',
options: {
strictMath: true,
plugins: [new AutoPrefixPlugin({ browsers: ['> 0.1%'] }), new CleanCssPlugin({})]
}
},
},
uglify: {
dist: {
src: 'static/js/bootstrap.js',
dest: 'build/dist/js/bootstrap.min.js',
}
},
watch: {
options: {
atBegin: true,
livereload: true,
},
less: {
files: ['static/less/*.less'],
tasks: 'less:dev',
},
hugo: {
files: ['layouts/**', 'content/**', 'static/js/**'],
tasks: 'hugo:dev',
},
all: {
files: ['Gruntfile.js'],
tasks: 'dev',
},
},
connect: {
mysite: {
options: {
hostname: '127.0.0.1',
port: 1342,
protocol: 'http',
base: 'build/dev',
livereload: true,
keepalive: true,
}
}
}
});
grunt.registerTask('hugo', function(target) {
var done = this.async();
var args = ["--destination=build/" + target];
if (target === 'dev') {
args.push('--baseUrl=http://127.0.0.1:1342');
args.push('--buildDrafts=true');
args.push('--buildFuture=true');
}
hugo = require('child_process').spawn('hugo', args, {stdio: 'inherit'});
hugo.on('exit', function() { done(true); });
hugo.on('error', function() { done(true); });
});
require('load-grunt-tasks')(grunt);
grunt.registerTask('dev', ['less:dev', 'hugo:dev']);
grunt.registerTask('default', ['less:dist', 'uglify', 'hugo:dist']);
grunt.registerTask('edit', ['connect', 'watch']);
};