This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
76 lines (65 loc) · 1.75 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
"use strict"; //eslint-disable-line
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
webfont: {
icons: {
src: 'svg/*.svg',
dest: 'build/',
destCss: 'scss/',
options: {
engine: "fontforge",
font: "ft-icons",
types: "eot,woff,ttf",
hashes: true,
stylesheet: "scss",
template: 'grunt-webfont-templates/origami.css',
htmlDemo: false
}
}
},
watch: {
'demo': {
files: ['main.scss', 'scss/*.scss', 'demo/src/*', 'svg/*'],
tasks: ['demo']
}
}
});
grunt.loadNpmTasks('grunt-webfont');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('demo', function() {
// Read svg directory for list of icons to pass to demo template
const fs = require('fs');
const files = fs.readdirSync('svg').filter(function(file) {
return file.indexOf(".svg") > -1;
});
const icons = files.map(function(file) {
return { name: file.slice(0, -4) };
});
const done = this.async();
fs.writeFileSync('demos/src/data.json', JSON.stringify({ icons: icons }), { encoding: 'utf-8' });
grunt.task.run(['webfont']);
grunt.util.spawn({
cmd: "origami-build-tools",
args: [
"demo",
"demos/src/config.json",
"--buildservice"
]
}, function() {
done();
});
});
grunt.registerTask('svgDemo', function(){
// Read svg directory for list of icons to pass to demo template
const fs = require('fs');
const files = fs.readdirSync('svg').filter(function(file) {
return file.indexOf(".svg") > -1;
});
const icons = files.map(function(file) {
return { name: file.slice(0, -4) };
});
fs.writeFileSync('demos/src/svg.json', JSON.stringify({ icons: icons }), { encoding: 'utf-8' });
});
grunt.registerTask('default', ["demo"]);
};