-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
204 lines (173 loc) · 4.26 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
"use strict"
# Listen on port 35729
LIVERELOAD_PORT = 35729
lrSnippet = require('connect-livereload')( port: LIVERELOAD_PORT )
folderMount = (connect, base) ->
console.log(base)
# Serve static files.
connect.static ( require("path").resolve base )
module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
connect:
options:
port: 9000
hostname: "localhost"
dev:
options:
middleware: (connect, options) ->
[
lrSnippet
folderMount(connect, ".tmp/public")
folderMount(connect, "public")
]
dist:
options:
middleware: (connect, options) ->
[
lrSnippet
folderMount(connect, "dist")
]
#Set compile settings
sass:
dev:
files: [
expand: true
cwd: "public/css/"
src: ["**/*.sass","**/*.scss"]
dest: ".tmp/public/css/"
ext: ".css"
]
less:
dev:
files: [
expand: true
cwd: "public/css/"
src: ["**/*.less"]
dest: ".tmp/public/css/"
ext: ".css"
]
stylus:
dev:
files: [
expand: true
cwd: "public/css/"
src: ["**/*.styl"]
dest: ".tmp/public/css/"
ext: ".css"
]
coffee:
grunt:
files:
".Gruntfile.js": "Gruntfile.coffee"
dev:
files: [
options:
bare: true
expand: true
cwd: "public/js/"
src: ['**/*.coffee']
dest: ".tmp/public/js/"
ext: '.js'
]
typescript:
dev:
files: [
expand: true
cwd: "public/js/"
src: ['**/*.ts']
dest: ".tmp/public/js/"
ext: '.js'
]
babel:
options:
sourceMap: true
dev:
files:[
expand: true
cwd: "public/js/"
src: ['**/*.es6']
dest: ".tmp/public/js/"
ext: '.js'
]
# watch files settings
watch:
options:
livereload: false
sass:
options:
cwd: "public/css"
files: ["**/*.sass", "**/*.scss"]
tasks: ["sass:dev"]
less:
options:
cwd: "public/css"
files: ["**/*.less"]
tasks: ["less:dev"]
stylus:
options:
cwd: "public/css"
files: ["**/*.styl"]
tasks: ["stylus:dev"]
babel:
options:
cwd: "public/js"
files: ["**/*.es6"]
tasks: ["babel:dev"]
coffee:
options:
cwd: "public/js"
files: ["**/*.coffee"]
tasks: ["coffee:dev"]
typescript:
options:
cwd: "public/js"
files: ["**/*.ts"]
tasks: ["typescript:dev"]
plain:
options:
cwd: "public"
livereload: LIVERELOAD_PORT
files: ["**/*.html", "css/**/*.css", "js/**/*.js"]
compiled:
options:
cwd: ".tmp/public"
livereload: LIVERELOAD_PORT
files: ["**/*.html", "css/**/*.css", "js/**/*.js"]
clean:
grunt:
src: ".Gruntfile.js"
dev:
src: [".tmp/**"]
dist:
src: ["dist/**"]
copy:
dist:
files:[
{
expand: true
cwd: 'public/'
src: ["**","!**/*.{coffee,ts,sass,scss,less,styl}"]
dest: "dist/"
},
{
expand: true,
cwd: ".tmp/public/"
src: ["**"],
dest: "dist/"
}
]
# browser open
open:
server:
path: "http://localhost:<%= connect.options.port %>"
# app: 'Google Chrome Canary'
# modules load
require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks
# task configure
grunt.registerTask "default", ->
grunt.task.run ["serve"];
grunt.registerTask "serve", ["clean", "coffee:grunt", "compile", "connect:dev", "open", "watch"]
grunt.registerTask "build", ["clean", "compile", "copy:dist"]
grunt.registerTask "dist", ["build", "connect:dist", "open", "watch"]
grunt.registerTask "compile", ["babel:dev", "coffee:dev", "typescript:dev", "sass:dev", "less:dev", "stylus:dev"]