Skip to content

Commit 7a18db2

Browse files
author
Lanny McNie
committed
Added combined option to the build process. Updated the readme.
Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent 9d94dcc commit 7a18db2

File tree

4 files changed

+80
-440
lines changed

4 files changed

+80
-440
lines changed

build/Gruntfile.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ module.exports = function (grunt) {
3434
}
3535
},
3636

37+
concat: {
38+
options: {
39+
separator: ''
40+
},
41+
build: {
42+
files: {
43+
'output/<%= pkg.name.toLowerCase() %>-<%= version %>.combined.js': getCombinedSource()
44+
}
45+
}
46+
},
47+
3748
// Build docs using yuidoc
3849
yuidoc: {
3950
compile: {
@@ -117,7 +128,44 @@ module.exports = function (grunt) {
117128
return config[name];
118129
}
119130

131+
function getCombinedSource() {
132+
var configs = [
133+
{cwd: '', config:'config.json', source:'source'}
134+
];
135+
136+
return combineSource(configs);
137+
}
138+
139+
function combineSource(configs) {
140+
// Pull out all the source paths.
141+
var sourcePaths = [];
142+
for (var i=0;i<configs.length;i++) {
143+
var o = configs[i];
144+
var json = grunt.file.readJSON(path.resolve(o.cwd, o.config));
145+
var sources = json[o.source];
146+
sources.forEach(function(item, index, array) {
147+
array[index] = path.resolve(o.cwd, item);
148+
});
149+
sourcePaths = sourcePaths.concat(sources);
150+
}
151+
152+
// Remove duplicates (Like EventDispatcher)
153+
var dups = {};
154+
var clean = [];
155+
for (i=0;i<sourcePaths.length;i++) {
156+
var src = sourcePaths[i];
157+
var cleanSrc = src.substr(src.lastIndexOf('src' + path.sep));
158+
if (dups[cleanSrc] == null) {
159+
clean.push(src);
160+
dups[cleanSrc] = true;
161+
}
162+
}
163+
164+
return clean;
165+
}
166+
120167
// Load all the tasks we need
168+
grunt.loadNpmTasks('grunt-contrib-concat');
121169
grunt.loadNpmTasks('grunt-contrib-uglify');
122170
grunt.loadNpmTasks('grunt-contrib-yuidoc');
123171
grunt.loadNpmTasks('grunt-contrib-compress');
@@ -161,4 +209,12 @@ module.exports = function (grunt) {
161209
grunt.registerTask('coreBuild', [
162210
"updateversion", "uglify", "docs", "copy:src"
163211
]);
212+
213+
/**
214+
* Task for exporting combined view.
215+
*
216+
*/
217+
grunt.registerTask('combine', 'Combine all source into a single, un-minified file.', [
218+
"concat"
219+
]);
164220
};

build/README.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
## We use grunt (http://gruntjs.com/) to manage our build process.
2-
3-
If you previously used an older process, you may want to clean up the node_modules and output folders.
1+
## TweenJS uses [Grunt](http://gruntjs.com/) to manage the build process.
42

53
## To use
64

75
### Install dependencies
86

97
Node (0.10.x or greater is required):
108

11-
# check the version
12-
node -v
9+
# check the version
10+
node -v
1311

14-
If your node is out of date, install the latest from:
15-
http://nodejs.org/
12+
If your node is out of date, install the latest from [NodeJS.org](http://nodejs.org/)
1613

1714
After node is setup, install the other dependencies:
1815

19-
# Install the grunt command line utility
20-
sudo npm install grunt-cli -g
16+
# Install the grunt command line utility
17+
sudo npm install grunt-cli -g
2118

22-
# Install all the dependencies for this project.
23-
npm install
19+
# Install all the dependencies for this project.
20+
npm install
2421

2522
### Setup
2623

@@ -37,7 +34,7 @@ Please adjust these settings to match your environment. All paths can either be
3734
### Building
3835
To export a release build for this library run:
3936

40-
grunt build
37+
grunt build
4138

4239
This command will:
4340

@@ -49,16 +46,23 @@ This command will:
4946
* Copy the built js file to ../lib
5047
* Copy All examples from ../examples to config.examples_out_path
5148

52-
To build the NEXT version run:
49+
**NEXT version**
50+
51+
The same process as above, but uses "NEXT" as the version. This is used to generate minified builds with the latest source between tags.
52+
53+
grunt next
54+
55+
**Combined File**
5356

54-
grunt next
57+
The same as the NEXT process, but will not minify the source code. All code formatting and comments are left intact.
5558

56-
Does the exact same process as above but uses NEXT as the version.
59+
grunt combine
5760

5861

5962
### All commands
6063

61-
grunt build - Build everything based on the version in package.json
62-
grunt next - Build everything using the NEXT version.
63-
grunt docs - Build only the docs
64-
grunt uglify - Create the Easel and MovieClip min files. (Will use NEXT as the version)
64+
* grunt build - Build everything based on the version in package.json
65+
* grunt next - Build everything using the NEXT version.
66+
* grunt combine - Build a NEXT version, but leave comments and formatting intact.
67+
* grunt docs - Build only the docs
68+
* grunt uglify - Create the TweenJS min file. (Will use NEXT as the version)

0 commit comments

Comments
 (0)