-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGruntfile.coffee
71 lines (64 loc) · 2.08 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
module.exports = (grunt) ->
# custom task to embed css into the view
grunt.registerTask 'embedcss', 'Embed CSS.', ->
sqwish = require('sqwish')
src = grunt.file.read("src/css/application.css")
minified_css = sqwish.minify(src)
combined = "(function(Handshake){" +
"Handshake.prototype._drawCss = function() {" +
"this.css = '" + minified_css + "';" +
"var style = document.createElement('style');" +
"style.type = 'text/css';" +
"if (style.styleSheet) {" +
"style.styleSheet.cssText = this.css;" +
"} else {" +
"style.appendChild(document.createTextNode(this.css));" +
"}" +
"return document.body.appendChild(style);" +
"};" +
"}(Handshake));"
grunt.file.write("src/handshake/css.js", combined)
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
banner: "/*! <%= pkg.name %>.js - <%= pkg.version %> - <%= grunt.template.today(\"yyyy-mm-dd\") %> - <%= pkg.author %> */\n"
files: [
"src/handshake.js",
"src/handshake/*.js"
]
uglify:
options:
banner: "<%= banner %>"
en:
src: ["build/handshake.js"]
dest: "build/handshake.min.js"
concat:
options:
banner: "<%= banner %>"
separator: '\n\n'
stripBanners : true
en:
src: "<%= files %>"
dest: "build/handshake.js"
jshint:
all: ['src/handshake.js', 'src/handshake/*.js']
connect:
server:
options:
hostname: "*"
port: 3000,
base: './public'
keepalive: true
simplemocha:
all:
src: 'test/*.js'
grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-uglify"
grunt.loadNpmTasks "grunt-contrib-connect"
grunt.loadNpmTasks "grunt-simple-mocha"
grunt.loadNpmTasks "grunt-contrib-jshint"
grunt.registerTask "test", ["simplemocha", "jshint"]
grunt.registerTask "default", ["embedcss", "jshint", "concat", "uglify", "connect"]
# Some available commands
# grunt
# grunt test
# grunt connect