-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
130 lines (109 loc) · 4.25 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
ALL_TASKS = ['jst:all', 'coffee:all', 'concat:all', 'stylus:all', 'clean:compiled', 'copy:all']
# formbuilder.js must be compiled in this order:
# 1. rivets-config
# 2. main
# 3. fields js
# 4. fields templates
module.exports = (grunt) ->
path = require('path')
exec = require('child_process').exec
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-concat')
grunt.loadNpmTasks('grunt-contrib-cssmin')
grunt.loadNpmTasks('grunt-contrib-jst')
grunt.loadNpmTasks('grunt-contrib-stylus')
grunt.loadNpmTasks('grunt-contrib-uglify')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-release')
grunt.loadNpmTasks('grunt-karma')
grunt.initConfig
pkg: '<json:package.json>'
srcFolder: 'src'
compiledFolder: 'compiled' # Temporary holding area.
distFolder: 'dist'
vendorFolder: 'vendor'
testFolder: 'test'
jst:
all:
options:
namespace: 'Formbuilder.templates'
processName: (filename) ->
signalStr = "templates/" #strip extra filepath and extensions
filename.slice(filename.indexOf(signalStr)+signalStr.length, filename.indexOf(".html"))
files:
'<%= compiledFolder %>/templates.js': '<%= srcFolder %>/templates/**/*.html'
coffee:
all:
files:
'<%= compiledFolder %>/scripts.js': [
'<%= srcFolder %>/scripts/underscore_mixins.coffee'
'<%= srcFolder %>/scripts/rivets-config.coffee'
'<%= srcFolder %>/scripts/main.coffee'
'<%= srcFolder %>/scripts/fields/*.coffee'
]
concat:
all:
files:
'<%= distFolder %>/formbuilder.js': '<%= compiledFolder %>/*.js'
'<%= vendorFolder %>/js/vendor.js': [
'bower_components/ie8-node-enum/index.js'
'bower_components/jquery/dist/jquery.js'
'bower_components/jquery-ui/ui/jquery.ui.core.js'
'bower_components/jquery-ui/ui/jquery.ui.widget.js'
'bower_components/jquery-ui/ui/jquery.ui.mouse.js'
'bower_components/jquery-ui/ui/jquery.ui.draggable.js'
'bower_components/jquery-ui/ui/jquery.ui.droppable.js'
'bower_components/jquery-ui/ui/jquery.ui.sortable.js'
'bower_components/jquery.scrollWindowTo/index.js'
'bower_components/lodash/dist/lodash.min.js'
'bower_components/underscore.mixin.deepExtend/index.js'
'bower_components/rivets/dist/rivets.js'
'bower_components/backbone/backbone.js'
'bower_components/backbone-deep-model/src/deep-model.js'
'bower_components/bootstrap/dist/js/bootstrap.js'
'bower_components/signature_pad/signature_pad.js'
'bower_components/node-uuid/uuid.js'
'input_mask/jquery.inputmask.bundle.js'
]
'<%= vendorFolder %>/css/vendor.css': [
'bower_components/font-awesome/css/font-awesome.css',
'bower_components/bootstrap/dist/css/bootstrap.css',
'bower_components/summernote/dist/summernote.css'
]
copy:
all:
expand: true,
flatten: true,
src: 'bower_components/font-awesome/fonts/*',
dest: '<%= vendorFolder %>/fonts/'
cssmin:
dist:
files:
'<%= distFolder %>/formbuilder-min.css': '<%= distFolder %>/formbuilder.css'
stylus:
all:
files:
'<%= compiledFolder %>/formbuilder.css': '<%= srcFolder %>/styles/**.styl'
'<%= distFolder %>/formbuilder.css': '<%= compiledFolder %>/**/*.css'
clean:
compiled:
['<%= compiledFolder %>']
uglify:
dist:
files:
'<%= distFolder %>/formbuilder-min.js': '<%= distFolder %>/formbuilder.js'
watch:
all:
files: ['<%= srcFolder %>/**/*.{coffee,styl,html}']
tasks: ALL_TASKS
# To test, run `grunt --no-write -v release`
release:
npm: false
karma:
unit:
configFile: '<%= testFolder %>/karma.conf.coffee'
grunt.registerTask 'default', ALL_TASKS
grunt.registerTask 'dist', ['cssmin:dist', 'uglify:dist']
grunt.registerTask 'test', ['dist', 'karma']