-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
147 lines (141 loc) · 5.3 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
sass = require 'node-sass'
module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
resourcesPath: 'app/Resources'
npmPath: 'node_modules'
assetsPath: 'web'
# Cleans up folders we will later copy to
clean: [
'<%= assetsPath %>/partials'
'<%= assetsPath %>/css'
'<%= assetsPath %>/images/sprite.svg'
'<%= assetsPath %>/js'
'<%= assetsPath %>/fonts'
]
# Copies stuff that needs to be copied
copy:
appTemplates:
expand: true
cwd: '<%= resourcesPath %>/views/frontend'
src: ['**/*.html']
dest: '<%= assetsPath %>/partials'
bootstrapFonts:
expand: true
cwd: '<%= npmPath %>/bootstrap-sass/assets/fonts/bootstrap/'
src: '*'
dest: '<%= assetsPath %>/fonts'
ngTagsInput:
expand: true
cwd: '<%= npmPath %>/ng-tags-input/build/'
src: 'ng-tags-input.bootstrap.min.css'
dest: '<%= assetsPath %>/css'
jQuery:
expand: true
cwd: '<%= npmPath %>/jquery/dist/'
src: 'jquery.min.js'
dest: '<%= assetsPath %>/js'
jQueryUi:
expand: true
cwd: '<%= npmPath %>/jquery-ui-dist/'
src: 'jquery-ui.min.js'
dest: '<%= assetsPath %>/js'
# Compiles JS from coffee, enables Node.js module support
browserify:
main:
files:
'<%= assetsPath %>/js/app.js': ['<%= resourcesPath %>/coffee/app.coffee']
options:
transform: ['coffeeify']
browserifyOptions:
extensions: ['.coffee']
# Compiles SASS to CSS
sass:
options:
sourceMap: true
implementation: sass
includePaths: ['node_modules']
dist:
files:
'web/css/main.css': '<%= resourcesPath %>/sass/main.sass'
# Watches for changes to SASS files and triggers compilation
watch:
sass:
files: ['<%= resourcesPath %>/sass/**/*.{sass,scss}']
tasks: ['sass', 'notify:sass']
js:
files: ['<%= resourcesPath %>/coffee/**/*.coffee']
tasks: ['browserify', 'notify:js']
angularTemplates:
files: ['<%= resourcesPath %>/views/frontend/**/*.html']
tasks: ['copy:appTemplates', 'notify:templates']
svgSprite:
files: ['<%= resourcesPath %>/images/icons/*.svg']
tasks: ['svgstore']
# Watches for changes to CSS and reloads page in browser
browserSync:
bsFiles:
src : ['<%= assetsPath %>/css/*.css']
options:
watchTask: true,
debugInfo: true,
proxy: 'localhost:8080'
open: false
# Generates SVG sprite from single files
svgstore:
options:
prefix : 'icon-'
svg:
viewBox : '0 0 100 100'
xmlns: 'http://www.w3.org/2000/svg'
default:
files:
'web/images/sprite.svg': ['<%= resourcesPath %>/images/icons/*.svg']
# Runs clientside unit tests with Karma
karma:
options:
frameworks: ['jasmine', 'browserify']
files: [
'app/Resources/coffee/app.coffee'
'node_modules/angular-mocks/angular-mocks.js'
'test/*Spec.coffee'
]
preprocessors:
'app/Resources/coffee/app.coffee': ['browserify']
'test/*Spec.coffee': ['browserify']
browserify:
debug: yes
transform: ['coffeeify']
extensions: ['.coffee']
bundleDelay: 1000
reporters: ['spec']
browsers: ['PhantomJS']
watch:
autoWatch: yes
once:
singleRun: yes
notify:
js:
options:
title: 'picapica build'
message: 'JS successfully built'
templates:
options:
title: 'picapica build'
message: 'templates successfully built'
sass:
options:
title: 'picapica build'
message: 'styles successfully built'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-sass'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-browser-sync'
grunt.loadNpmTasks 'grunt-svgstore'
grunt.loadNpmTasks 'grunt-browserify'
grunt.loadNpmTasks 'grunt-karma'
grunt.loadNpmTasks 'grunt-notify'
grunt.registerTask 'live', ['browserSync', 'watch']
grunt.registerTask 'test', ['karma:once']
grunt.registerTask 'default', ['clean', 'copy', 'browserify', 'sass', 'svgstore']