-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
143 lines (140 loc) · 4.01 KB
/
Gruntfile.js
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
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/* <%= pkg.name %>\n' +
'* <%= pkg.homepage %> \n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %>' +
' <%= pkg.author.name %>\n' +
'* Licensed under AGPLv3. */'
},
clean: {
dist: ['dist'],
temp: ['dist/temp']
},
exec: {
gzip: {
cmd: "find dist/ -type f | while read f; do gzip -9 $f; done"
},
move: {
cmd: "find dist/ -type f -name '*.gz' | while read f; do mv \"$f\" \"${f%.gz}\"; done"
}
},
concat: {
options: { banner: '<%= meta.banner %>' },
dist: {
src: ['lib/modernizr.min.js', 'lib/underscore.min.js',
'lib/backbone.min.js', 'dist/temp/<%= pkg.name %>.min.js'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
copy: {
dist: {
files: [
{ dest: 'dist/', src: ['favicon.ico', 'people.txt', 'robots.txt', 'sitemap.xml'] },
{ dest: 'dist/gfx/', cwd: 'gfx/', src: ['*'], expand: true, filter: 'isFile' },
{ dest: 'dist/lib/', cwd: 'lib/', src: ['zepto.min.js', 'jquery.min.js', 'rgbcolor.min.js', 'canvg.min.js'], expand: true }
]
}
},
cssmin: {
options: { banner: '<%= meta.banner %>' },
compress: {
files: {
'dist/<%= pkg.name %>.min.css': ['css/inuit.css', 'css/reinmerke.css']
}
}
},
jshint: {
options: { jshintrc: 'jshintrc' },
node: {
options: { node: true },
files: {
src: ['Gruntfile.js']
}
},
browser: {
options: {
globals: {
REIN: true, Backbone: true, _: true, $: true, localStorage: true
}
},
files: {
src: ['src/app.js', 'src/utils.js', 'src/mark_register.js',
'src/cuts.js', 'src/modules/widgets.js', 'src/modules/list.js',
'src/modules/list.js', 'src/setup.js']
}
}
},
jst: {
options: {
namespace: 'REIN.templates',
processName: function (filename) {
return filename.split('/').pop().split('.')[0];
}
},
files: {
'src/templates/compiled.js': ['src/templates/*.html']
}
},
replace: {
dist: {
options: {
variables: { 'version': '<%= pkg.version %>' }
},
files: {
'dist/index.html': 'dist/temp/index.html',
'dist/': ['rein.appcache']
}
}
},
targethtml: {
dist: {
files: {
'dist/temp/index.html': 'index.html'
}
}
},
uglify: {
build: {
files: {
'dist/temp/<%= pkg.name %>.min.js': [
'src/app.js', 'src/utils.js', 'src/mark_register.js',
'src/cuts.js', 'src/templates/compiled.js',
'src/modules/widgets.js', 'src/modules/main.js',
'src/modules/list.js', 'src/setup.js']
}
}
},
watch: {
templates: {
files: ['src/templates/*.html'],
tasks: ['jst']
},
nodescripts: {
files: ['<%= jshint.node.files.src %>'],
tasks: ['jshint:node']
},
tests: {
files: ['src/**/*.js', 'test/**/*_test.js'],
tasks: ['jshint:browser']
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jst');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-targethtml');
grunt.registerTask('default', [
'jshint', 'jst', 'clean:dist', 'uglify', 'concat', 'cssmin', 'targethtml',
'replace', 'copy', 'clean:temp', 'exec:gzip', 'exec:move'
]);
};