Skip to content

Commit 73429e0

Browse files
author
Lanny McNie
committed
Added a combined option to the build process. Updated the readme.
Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent 3387c4d commit 73429e0

4 files changed

Lines changed: 84 additions & 444 deletions

File tree

build/Gruntfile.js

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

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

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

build/README.md

Lines changed: 27 additions & 23 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+
## PreloadJS 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,28 +34,35 @@ 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

44-
* Update the version.js file(s).
41+
* Update the version.js file(s) with the current date and version number
4542
* Create the {PROJECT_NAME}-{VERSION}.min.js file
46-
* Compile the docs to config.docs_out_path
47-
* Create a zip file of the docs/
48-
* Copy the docs zip to ../docs
43+
* Compile the documentation to config.docs_out_path
44+
* Create a zip file of the documentation
45+
* Copy the documentation zip to ../docs
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 PreloadJS min file. (Will use NEXT as the version)

0 commit comments

Comments
 (0)