This repository has been archived by the owner on Jan 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
209 lines (186 loc) · 6.72 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Generated on 2014-02-28 using generator-webapp 0.4.7
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Define the configuration for all the tasks
grunt.initConfig({
// Package Config
'pkg': grunt.file.readJSON('package.json'),
'amdClean': function(path) {
var amdclean = module.require('amdclean'),
outputFile = path,
cleanedCode = amdclean.clean({
'filePath': outputFile
});
cleanedCode = cleanedCode.replace(/jquery/g, 'jQuery');
cleanedCode = cleanedCode.replace(/underscore/g, '_');
cleanedCode = cleanedCode.replace(/backbonemarionette/g, 'Marionette');
return cleanedCode;
},
// Project settings
yeoman: {
// Configurable paths
app: 'src',
dist: 'dist',
banner: '/*\n' +
'** MarionetteTransition v<%= pkg.version %>\n' +
'** Description: Make your dancing Marionette apps transition beautifully.\n' +
'** Author: Jarrod Payne\n' +
'** Company: Webotomy\n' +
'** License: MIT\n' +
'**\n' +
'** Thanks to @jasonlaster and @jmeas for the help.\n' +
'*/ \n\n'
},
// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['jshint']
},
gruntfile: {
files: ['Gruntfile.js']
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
},
server: '.tmp'
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'!<%= yeoman.app %>/scripts/vendor/*',
]
},
// Copies remaining files to places other tasks can use
copy: {
amd: {
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/scripts/',
dest: '<%= yeoman.dist %>/amd',
src: [
'{,*/}*.js',
]
}
},
requirejs: {
dist: {
options: {
baseUrl: '<%= yeoman.app %>/scripts',
paths: {
'jquery': '../bower_components/jquery/dist/jquery',
'underscore': '../bower_components/underscore/underscore',
'backbone': '../bower_components/backbone/backbone',
'backbone.marionette': '../bower_components/backbone.marionette/lib/backbone.marionette',
'TweenLite': '../bower_components/gsap/src/uncompressed/TweenLite',
'CSSPlugin': '../bower_components/gsap/src/uncompressed/plugins/CSSPlugin'
},
shim: {
'CSSPlugin': {
exports: 'CSSPlugin',
deps: ['TweenLite']
},
'TweenLite': {
exports: 'TweenLite'
}
},
include: ['MarionetteTransition'],
exclude: ['jquery', 'underscore', 'backbone', 'backbone.marionette', 'TweenLite', 'CSSPlugin'],
out: '<%= yeoman.dist %>/MarionetteTransition.js',
optimize: 'none',
skipModuleInsertion: true,
onModuleBundleComplete: function(data) {
var fs = module.require('fs'),
cleanedCode = grunt.config.get('amdClean')(data.path);
grunt.log.writeln('this is a test');
fs.writeFileSync(data.path, cleanedCode);
}
}
}
},
umd: {
main: {
src: '<%= yeoman.dist %>/MarionetteTransition.js',
objectToExport: 'MarionetteTransition',
template: 'umd',
dest: '<%= yeoman.dist %>/MarionetteTransition.js',
deps: { 'default': ['jQuery', '_', 'Marionette', 'TweenLite', 'CSSPlugin'] }
}
},
// Add Banner
'concat': {
options: {
banner: '<%= yeoman.banner %>',
stripBanners: true
},
amd: {
src: '<%= yeoman.dist %>/amd/MarionetteTransition.js',
dest: '<%= yeoman.dist %>/amd/MarionetteTransition.js'
},
umd: {
src: '<%= yeoman.dist %>/MarionetteTransition.js',
dest: '<%= yeoman.dist %>/MarionetteTransition.js'
}
},
// Minify JS
'uglify': {
umd: {
src: '<%= yeoman.dist %>/MarionetteTransition.js',
dest: '<%= yeoman.dist %>/MarionetteTransition.min.js'
}
},
// Keep bower.json in sync with package.json
/*jshint camelcase: false */
update_json: {
options: {
indent: ' '
},
bower: {
indent: ' ',
src: 'package.json',
dest: 'bower.json', // where to write to
// the fields to update, as a String Grouping
fields: ['name', 'version', 'description', 'keywords', 'homepage', 'license']
}
}
});
grunt.registerTask('build', [
'clean:dist',
'copy:amd',
'requirejs:dist',
'umd:main',
'concat:amd',
'concat:umd',
'uglify:umd',
'update_json:bower'
]);
grunt.registerTask('default', [
'newer:jshint',
'build'
]);
};