-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.coffee
79 lines (71 loc) · 2.09 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
module.exports = (grunt) ->
grunt.initConfig
useminPrepare:
html: [
'app/**/@*.latte'
]
options:
dest: '.'
netteBasePath:
basePath: 'www'
options:
removeFromPath: [
'app/FrontModule/templates/',
'app/AdminModule/templates/',
'app\\FrontModule\\templates\\',
'app\\AdminModule\\templates\\',
'app\\templates\\',
'app/templates/'
]
concat:
options:
separator: '\n',
process: (src, filepath) ->
cssPatt = new RegExp("^www(/.*/).*.css$")
#filter out everithing except css files
file = cssPatt.exec(filepath)
if file
urlPatt = /url\(\'?([^\'\:\)]*)\'?\)/g
console.log "In file: " + filepath
#replace every url(...) with its absolute path
return src.replace(urlPatt, (match, p1) ->
console.log " * " + match + " -> " + "url('" + file[1] + p1 + "')"
"url('" + file[1] + p1 + "')"
)
src
watch:
coffee:
files: 'www/assets/coffee/*.coffee'
tasks: 'coffee:compile'
options:
livereload: true
less:
files: 'www/assets/css/*.less'
tasks: 'less:dev'
options:
livereload: true
misc:
files: ['www/assets/css/*.css', 'www/assets/js/*.js']
options:
livereload: true
# These plugins provide necessary tasks.
grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-usemin'
grunt.loadNpmTasks 'grunt-nette-basepath'
# Default task.
grunt.registerTask 'deploy', [
'useminPrepare'
'netteBasePath'
'concat'
'uglify'
'cssmin'
]
#grunt.registerTask 'watch', ['watch:less', 'watch2:coffee']
grunt.registerTask 'compile', [
'less:dev', 'coffee:compile'
]