forked from Harry-Chen/Learn-Helper
/
Gruntfile.coffee
102 lines (98 loc) · 1.97 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
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
module.exports = (grunt) ->
'use strict'
#############
# plugins
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-stylus'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-iced-coffee'
grunt.registerMultiTask 'template', ->
for file in @files
src=file.src[0]
dest=file.dest
cont=grunt.template.process grunt.file.read(src, encoding: 'utf-8')
cont=cont.replace(/\r\n/g, '\n')
grunt.file.write(dest, cont, encoding: 'utf-8')
############
# main
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
template:
manifest:
files: [
{src: 'src/manifest.json', dest: 'build/manifest.json' }
]
stylus:
all:
options:
urlfunc: 'embedurl'
compress: false
"include css": true
files: [
{
expand: true
cwd: 'src/stylus/'
src: ['**/*.styl', '!**/_*.styl']
dest: 'build/css/'
ext: '.css'
}
]
coffee:
compile:
options:
runtime: 'inline'
files: [
{
expand: true
cwd: 'src/iced/'
src: ['**/*.iced', '**/*.coffee']
dest: 'build/js/'
ext: '.js'
}
]
copy:
asset:
files: [
{
expand: true
cwd: 'src/asset/'
src: '**/*'
dest: 'build/'
},
{
expand: true
cwd: 'src/html/'
src: '**/*'
dest: 'build/'
}
]
watch:
options:
spawn: false
asset:
files: ['src/asset/**/*', 'src/html/**/*']
tasks: ['copy:asset']
coffee:
files: ['src/iced/**/*']
tasks: ['coffee']
css:
files: ['src/stylus/**/*']
tasks: ['stylus']
clean:
files: ['build', 'tmp', 'dist']
grunt.registerTask 'manifest', [
'template:manifest'
]
grunt.registerTask 'default', [
'stylus'
'coffee:compile'
'copy:asset'
'manifest'
]
grunt.registerTask 'dev', [
'default'
'watch'
]