-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
107 lines (90 loc) · 2.27 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'./public/css/styles.css': './application/assets/sass/styles.scss'
}
},
},
handlebars: {
options: {
namespace: 'JST',
// Remove path and extension from template name
processName: function(filePath) {
return filePath.replace(/^(.*[\\\/])/, '').replace(/\.hbs$/, '');
}
},
app: {
files: {
'./application/assets/spa/templates/compiled.js': './application/assets/spa/templates/*.hbs'
}
}
},
concat: {
options: {
sourceMap: true,
separator: ';'
},
app: {
src: [
'./application/assets/spa/templates/compiled.js',
'./application/assets/spa/helpers/*.js',
'./application/assets/spa/collections/*.js',
'./application/assets/spa/models/*.js',
'./application/assets/spa/views/*.js',
'./application/assets/spa/app.js'
],
dest: './public/js/app.js'
}
},
uglify: {
options: {
banner: '/* <%= pkg.name %>, built <%= grunt.template.today() %> */\n',
compress: true,
mangle: true,
sourceMap: true
},
lib: {
src: [
'./node_modules/jquery/dist/jquery.js',
'./node_modules/underscore/underscore.js',
'./node_modules/backbone/backbone.js',
'./node_modules/handlebars/dist/handlebars.runtime.js'
],
dest: './public/js/lib.min.js'
},
app: {
files: {
'./public/js/app.min.js': ['<%= concat.app.dest %>']
}
}
},
watch: {
sass: {
files: ['./application/assets/sass/*.scss'],
tasks: ['sass']
},
js: {
files: [
'./application/assets/spa/**/*.js',
'./application/assets/spa/*.js',
'./application/assets/spa/templates/*.hbs'
],
tasks: ['handlebars', 'concat', 'uglify']
}
}
});
// Load the plugins that prvide the various Grunt tasks
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['sass', 'handlebars', 'concat', 'uglify']);
}