This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
83 lines (73 loc) · 2.59 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
module.exports = (grunt) ->
config =
pkg: grunt.file.readJSON("package.json")
jshintrc: grunt.file.readJSON(".jshintrc")
banner: "/*! <%= pkg.name %> (<%= grunt.template.today(\"yyyy-mm-dd\") %>) */"
dir:
app: "app"
dist: "app/dist"
concat:
vendor:
files: [
src: [
"<%= dir.app %>/js/vendor/*.js"
]
dest: "<%= dir.dist %>/vendor.js"
]
license:
files: [
src: [
"<%= dir.app %>/js/vendor/_license.js"
"<%= dir.dist %>/vendor.min.js"
]
dest: "<%= dir.dist %>/vendor.min.js"
]
cssmin:
app:
options:
banner: "<%= banner %>"
keepSpecialComments: 0
report: "min"
files: [
src: "<%= dir.dist %>/app.css"
dest: "<%= dir.dist %>/app.min.css"
]
handlebars:
compile:
options:
namespace: "templates"
processName: (filepath) ->
filepath.replace("#{config.dir.app}/js/hbs/", "")
files: [
src: "<%= dir.app %>/js/hbs/**/*.hbs"
dest: "<%= dir.dist %>/templates.js"
]
uglify:
vendor:
options:
report: "min"
files: [
src: "<%= dir.dist %>/vendor.js"
dest: "<%= dir.dist %>/vendor.min.js"
]
jshint:
options: "<%= jshintrc %>"
all: "<%= dir.app %>/js/*.js"
watch:
js:
files: ["<%= dir.app %>/js/*.js"]
tasks: ["jshint:all"]
hbs:
files: ["<%= dir.app %>/js/hbs/**/*.hbs"]
tasks: ["handlebars"]
grunt.initConfig(config)
# load all grunt tasks
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks)
# on watch events configure to only run on changed file
grunt.event.on("watch", (action, filepath) ->
grunt.config(["jshint", "all"], filepath)
)
grunt.registerTask("default", ["build"])
grunt.registerTask("build", ["cssbuild", "jsbuild"])
grunt.registerTask("cssbuild", ["cssmin"])
grunt.registerTask("jsbuild", ["concat:vendor", "uglify", "concat:license"])