-
Notifications
You must be signed in to change notification settings - Fork 421
/
Copy pathGruntfile.js
178 lines (159 loc) · 4.22 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
/*global module:false*/
module.exports = function(grunt) {
'use strict';
// @todo: move to json file
var standards = {
ourLanguages : ['en', 'es'],
defaultFile : 'index',
defaultExt : '.html',
// change this to have the 'index' file be another language
defaultLanguage : 'en'
};
// output build time stats
require('time-grunt')(grunt);
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
// combine our files into one file, language by language
assemble: {
options: {
marked: {
sanitize: false
},
flatten : true,
layout: './src/_layouts/main.hbs'
},
en: {
options : {
data : 'src/content/en/build/data.json'
},
files : {
'en.html' : ['src/content/en/build/en.hbs']
}
},
/*es: {
options : {
data : 'src/content/es/build/data.json'
},
files : {
'es.html' : ['src/content/es/build/es.hbs']
}
},*/
},
// clean up after the previous build
clean: {
build : (function(){
var arr = [];
// we iterate over the languages and create our list of output files
standards.ourLanguages.forEach(function(val){
arr.push(val + standards.defaultExt);
});
// add the default file to the list since it will be replaced by "copy"
arr.push(standards.defaultFile + standards.defaultExt);
return arr;
}()),
assets: ['_assets/**/*']
},
// concatenate the js files into one
concat: {
js: {
options: {
separator: ';',
},
files: {
'_assets/js/main.js': ['src/js/**/*.js','!src/js/vendor/jquery-*min.js']
}
}
},
// connect to the local server
connect: {
server: {
options: {
port: 8000,
hostname: '127.0.0.1',
keepalive: true
}
}
},
// copy the specified default language to the specified file
copy: {
assets: {
expand: true,
cwd: 'src/js/vendor/',
src: ['jquery*min.js'],
dest: '_assets/js/vendor/'
},
// mat be replaced by imagemin
images: {
expand: true,
cwd: 'src/img',
src: ['**/*.{png,jpg,gif,svg,ico}'],
dest: '_assets/img/'
},
realeaseLanguage : {
src : standards.defaultLanguage + standards.defaultExt,
dest : standards.defaultFile + standards.defaultExt
}
},
// run sass to generate the css
sass: {
global: {
options: {
sourceMap: true,
sourceComments: false,
outputStyle: 'expanded'
},
files: [{
expand: true,
cwd: 'src/scss/',
src: ['*.scss', '!js-only.scss'],
dest: '_assets/css/',
ext: '.css'
},
],
}
},
// watch the file system for new changes
watch: {
css: {
files: ['src/scss/**/*.scss'],
tasks: ['sass']
},
html: {
files: ['src/_layouts/**.*', 'src/content/en/**/*.*'],
tasks: ['assemble','copy']
},
img: {
files: ['src/img/**/*.{png,jpg,gif}'],
tasks: ['copy:images'] // may be replaced by imagemin
},
js: {
files: ['src/js/**/*.js'],
tasks: ['concat', 'uglify', 'copy:assets']
}
},
// minify the js
uglify: {
target: {
files: {
'_assets/js/main.min.js': ['_assets/js/main.js']
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('assemble');
// Default task.
grunt.registerTask('cleanup', ['clean']);
grunt.registerTask('server', ['connect']);
grunt.registerTask('default', ['clean', 'sass', 'concat', 'uglify', 'assemble', 'copy']);
grunt.registerTask('dev', ['watch']);
};