Skip to content

Commit fc79c96

Browse files
author
Lanny McNie
committed
Added a combined option to the build process. Updated the readme.
Signed-off-by: Lanny McNie <[email protected]>
1 parent cd1e760 commit fc79c96

File tree

5 files changed

+81
-868
lines changed

5 files changed

+81
-868
lines changed

build/Gruntfile.js

Lines changed: 56 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: {
@@ -118,7 +129,44 @@ module.exports = function (grunt) {
118129
return config[name];
119130
}
120131

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

build/README.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
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+
## SoundJS 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

25-
### Setup
22+
# Setup
2623

2724
You'll need to change the default settings to suit your work environment.
2825
We have 2 config files:
@@ -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 SoundJS and FlashPlugin min files. (Will use NEXT as the version)

0 commit comments

Comments
 (0)