forked from kakmys/www.navi.cc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.coffee
More file actions
252 lines (227 loc) · 7.34 KB
/
Gruntfile.coffee
File metadata and controls
252 lines (227 loc) · 7.34 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
lrSnippet = require("grunt-contrib-livereload/lib/utils").livereloadSnippet
mountFolder = (connect, dir) ->
connect.static require("path").resolve(dir)
config:
locales: ["ru", "en", "ua", "pl"]
module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
meta: grunt.file.readJSON('package.json')
pkg: grunt.file.readJSON('package.json')
distdir: 'dist'
tempdir: 'temp'
# Paths
src:
js: ['src/i18n/**/*.js', 'src/common/**/*.js', 'src/app/**/*.js', 'dist/tmp/**/*.js']
html: ['src/index.html']
tpl: ['src/app/**/*.tpl.html']
#css: ['src/css']
#less: ['src/less/*.less'] # recess:build doesn't accept ** in its file patterns
less: ['src/less/main.less'] # recess:build doesn't accept ** in its file patterns
# CoffeeScript
coffee:
dist:
files:
"<%= distdir %>/js/*.js": ["src/coffee/**/*.coffee"]
test:
files:
"test/spec/*.js": ["test/spec/coffee/**/*.coffee"]
less:
dist:
files:
"<%= distdir %>/css/<%= pkg.name %>.css": ["<%= src.less %>"]
copy:
assets:
files: [
dest: '<%= distdir %>/'
src: ['**']
cwd: 'src/assets/'
expand: true
]
templates:
files: [
dest: '<%= distdir %>/templates'
src: ['**/*.tpl.html']
cwd: 'src/app'
expand: true
]
sprites:
files: [
src: ["sprite-marker.png"]
dest: "dist/css/"
cwd: 'src/images'
expand: true
]
jade:
templates:
options:
client: false
# pretty: false
doctype: '5'
pretty: true
data:
debug: false
title: 'My awesome application'
# extension: '.tpl.html'
# locals:
# _: grunt.file.readJSON('src/i18n/ru.json')
# files: grunt.file.expandMapping(["**/*.jade"], "dist/templates/",
files: grunt.file.expandMapping(["**/*.jade"], "dist/templates/",
# cwd: "src/app/templates"
cwd: "src/app"
rename: (destBase, destPath) ->
# console.log "Hello", destBase, destPath
destBase + destPath.replace(/\.jade$/, ".tpl.html")
# '<%= tempdir %>/templates': ['src/app/templates/*.jade']
# '<%= distdir %>/templates/': ['src/app/templates/*.jade']
)
# jade:
# templates: {
# files: {
# 'dist/templates/': ['src/app/templates*.jade']
# },
# options: {
# client: false,
# locals: {
# title: 'Welcome to my website!'
# }
# }
# }
html2js:
#templates:
# options:
# base: '<%= distdir %>/'
# src: ['<%= distdir %>/templates/**/*.tpl.html']
# dest: '<%= distdir %>/js/templates.js'
# module: 'templates'
templates:
options:
base: '<%= distdir %>'
module: 'templates'
src: ['<%= distdir %>/templates/**/*.tpl.html']
dest: '<%= distdir %>/js/templates.js'
concat:
dist:
src:['<banner:meta.banner>', '<%= src.js %>'],
dest:'<%= distdir %>/js/<%= pkg.name %>.js'
# src:['src/i18n/ru.jade', 'src/*.jade']
# dest:'<%= distdir %>/tmp/jade/*.jade'
oversprite:
all:
# // List of sprites to create
spritelist: [
# // List of images to add to sprite
src: ["src/images/*.png"]
# // Address of target image
# dest: "dist/css/sprite-marker.png"
dest: "src/images/sprite-marker.png"
# // OPTIONAL: Image placing algorithm: top-down, left-right, diagonal, alt-diagonal
algorithm: "alt-diagonal"
# // OPTIONAL: Rendering engine: auto, canvas, gm
engine: "gm"
# // OPTIONAL: Preferences for resulting image
exportOpts:
# // Image formst (buy default will try to use dest extension)
format: "png"
# // Quality of image (gm only)
quality: 90
# ,
# # // Second sprite config
# src: ["src/images/img2.jpg", "images/img3.gif"]
# dest: "dist/img/sprite-other.jpg"
]
# // List of css to replace images
csslist: [
# // Source css file
src: "src/images/style-sprite.css"
# src: "style-sprite.css"
# // Target css file, can be the same as source
# dest: "src/images/sprite-marker.css"
dest: "dist/css/sprite-marker.css"
# // OPTIONAL: Normalization string. Will be added to css dir path, before paths in css.
# // Use if you move the css and paths to images aren't resolving correctly now.
# base: "../../../dist/css/images"
# base: "../../../src/images/marker/"
# base: "src"
# base: "../dist/css/"
# ,
# # // Second css config
# src: "style.ie.css"
# dest: "sprite.ie.css"
]
clean:
dist: ['<%= distdir %>/*']
sprites: ["src/images/sprite-*.png", "src/images/sprite-*.css"]
connect:
livereload:
options:
port: 9001
hostname: 'localhost'
middleware: (connect) ->
[
lrSnippet,
mountFolder(connect, 'dist')
#mountFolder(connect, yeomanConfig.app)
]
regarde:
html:
files: '<%= src.html %>'
tasks: ['index']
htmltemplate:
files: ['src/app/**/*.tpl.html']
tasks: ['copy:templates']
js:
files: ['src/i18n/**/*.js', 'src/common/**/*.js', 'src/app/**/*.js']
tasks: ['concat']
template:
files: ['<%= distdir %>/templates/**/*.tpl.html']
tasks: ['html2js', 'concat']
livereload:
files: ['<%= distdir %>/**']
tasks: ['livereload']
jade:
# files: ['src/app/templates/*.jade']
files: ['src/app/**/*.jade']
tasks: ['jade', 'html2js', 'concat']
less:
files: ['src/less/*.less']
tasks: ['less']
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-less"
grunt.loadNpmTasks "grunt-contrib-clean"
#grunt.loadNpmTasks "grunt-contrib-jade"
# grunt.loadNpmTasks "grunt-jade"
grunt.loadNpmTasks "grunt-contrib-jade"
grunt.loadNpmTasks "grunt-html2js"
grunt.loadNpmTasks "grunt-contrib-connect"
grunt.loadNpmTasks "grunt-contrib-livereload"
grunt.loadNpmTasks "grunt-regarde"
grunt.loadNpmTasks "grunt-oversprite"
# grunt-contrib-watch now not work with livereload :(
#grunt.loadNpmTasks "grunt-contrib-watch"
# HTML stuff
grunt.registerTask 'index', 'Process index.html', ->
grunt.file.copy 'src/index.html', 'dist/index.html',
process: grunt.template.process
# Sprites
grunt.registerTask "sprites", [
"oversprite", "copy:sprites", "clean:sprites"
]
# Build
grunt.registerTask "build", [
# "clean", "jade", "less", "copy", "html2js", "index", "concat"
"clean", "jade", "less", "copy", "index", "concat"
]
# Development server
grunt.registerTask 'server', [
'build',
'livereload-start',
'connect:livereload',
#'connect',
'regarde'
#'open',
#'watch'
]
grunt.registerTask "default", ["build"]