forked from CodeByZach/pace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
55 lines (40 loc) · 1.4 KB
/
Gruntfile.coffee
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
Path = require('path')
fs = require('fs')
ThemeUtils = require('./docs/lib/themes.coffee')
module.exports = (grunt) ->
grunt.registerTask 'themes', 'Compile the pace theme files', ->
done = @async()
options = grunt.config('themes')
grunt.file.glob options.src, (err, files) ->
for file in files
body = ThemeUtils.compileTheme fs.readFileSync(file).toString()
body = "/* This is a compiled file, you should be editing the file in the templates directory */\n" + body
name = Path.basename file
name = name.replace '.tmpl', ''
path = Path.join options.dest, name
fs.writeFileSync path, body
done()
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
coffee:
compile:
files:
'pace.js': 'pace.coffee'
'docs/lib/themes.js': 'docs/lib/themes.coffee'
watch:
coffee:
files: ['pace.coffee', 'docs/lib/themes.coffee', 'templates/*']
tasks: ["coffee", "uglify", "themes"]
uglify:
options:
banner: "/*! <%= pkg.name %> <%= pkg.version %> */\n"
dist:
src: 'pace.js'
dest: 'pace.min.js'
themes:
src: 'templates/*.tmpl.css'
dest: 'themes'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.registerTask 'default', ['coffee', 'uglify', 'themes']