Skip to content

Commit 1477534

Browse files
author
Lanny McNie
committed
Added combined option to build process, and updated the readme.
Signed-off-by: Lanny McNie <lanny@gskinner.com>
1 parent 1b2bc23 commit 1477534

File tree

3 files changed

+91
-30
lines changed

3 files changed

+91
-30
lines changed

build/Gruntfile.js

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

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

144+
function getCombinedSource() {
145+
var configs = [
146+
{cwd: '', config:'config.json', source:'easel_source'}
147+
];
148+
149+
return combineSource(configs);
150+
}
151+
152+
function combineSource(configs) {
153+
// Pull out all the source paths.
154+
var sourcePaths = [];
155+
for (var i=0;i<configs.length;i++) {
156+
var o = configs[i];
157+
var json = grunt.file.readJSON(path.resolve(o.cwd, o.config));
158+
var sources = json[o.source];
159+
sources.forEach(function(item, index, array) {
160+
array[index] = path.resolve(o.cwd, item);
161+
});
162+
sourcePaths = sourcePaths.concat(sources);
163+
}
164+
165+
// Remove duplicates (Like EventDispatcher)
166+
var dups = {};
167+
var clean = [];
168+
for (i=0;i<sourcePaths.length;i++) {
169+
var src = sourcePaths[i];
170+
var cleanSrc = src.substr(src.lastIndexOf('src' + path.sep));
171+
if (dups[cleanSrc] == null) {
172+
clean.push(src);
173+
dups[cleanSrc] = true;
174+
}
175+
}
176+
177+
return clean;
178+
}
179+
133180
// Load all the tasks we need
181+
grunt.loadNpmTasks('grunt-contrib-concat');
134182
grunt.loadNpmTasks('grunt-contrib-uglify');
135183
grunt.loadNpmTasks('grunt-contrib-yuidoc');
136184
grunt.loadNpmTasks('grunt-contrib-compress');
@@ -174,4 +222,13 @@ module.exports = function (grunt) {
174222
grunt.registerTask('coreBuild', [
175223
"updateversion", "uglify", "docs", "copy:src"
176224
]);
225+
226+
/**
227+
* Task for exporting combined view.
228+
*
229+
*/
230+
grunt.registerTask('combine', 'Combine all source into a single, un-minified file.', [
231+
"concat"
232+
]);
233+
177234
};

build/README.md

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
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+
## EaselJS 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

17-
After node is setup, install the other dependances:
14+
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

27-
You'll need to change the default settings to suit your work environment.
28-
We have 2 config files:
24+
You'll need to change the default settings to suit your work environment. We have 2 config files:
2925

30-
* config.json - Is meant to be in git and pushed to all developers.
31-
* config.local.json - Is added to .gitignore and and only for your local setup (any settings in here will override those in config.json)
26+
* config.json: Meant to be in git and pushed to all developers.
27+
* config.local.json: Added to .gitignore and and only for your local setup (any settings in here will override those in config.json)
3228

3329
Please adjust these settings to match your environment. All paths can either be relative from the build folder, or absolute paths.
3430

@@ -37,28 +33,35 @@ Please adjust these settings to match your environment. All paths can either be
3733
### Building
3834
To export a release build for this library run:
3935

40-
grunt build
36+
grunt build
4137

4238
This command will:
4339

44-
* Update the version.js file(s).
40+
* Update the version.js file(s) with the current date and version number
4541
* 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
49-
* Copy the built js file to ../lib
50-
* Copy All examples from ../examples to config.examples_out_path
42+
* Compile the documentation to config.docs_out_path
43+
* Create a zip file of the documentation
44+
* Copy the documentation zip to ../docs
45+
* Copy the generated .js file to ../lib
46+
* Copy All examples from ../examples to config.examples_out_path (part of the overall build process)
47+
48+
**NEXT version**
49+
50+
The same process as above, but uses "NEXT" as the version. This is used to generate minified builds with the latest source between tags.
51+
52+
grunt next
5153

52-
To build the NEXT version run:
54+
**Combined File**
5355

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

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

5860

5961
### All commands
6062

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)
63+
* grunt build - Build everything based on the version in package.json
64+
* grunt next - Build everything using the NEXT version.
65+
* grunt combine - Build a NEXT version, but leave comments and formatting intact.
66+
* grunt docs - Build only the docs
67+
* grunt uglify - Create the Easel and MovieClip min files. (Will use NEXT as the version)

build/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"logo": "http://createjs.com/resources/SuiteIcons/EaselJS/docs-icon-EaselJS.png",
77
"devDependencies": {
88
"grunt": "~0.4.1",
9+
"grunt-contrib-concat":"~0.3.0",
910
"grunt-contrib-uglify": "~0.2.1",
1011
"grunt-contrib-yuidoc": "~0.4.0",
1112
"grunt-contrib-compress": "~0.5.0",

0 commit comments

Comments
 (0)