Skip to content

Commit

Permalink
all.js -> fabric.js. Closes #1049
Browse files Browse the repository at this point in the history
  • Loading branch information
kangax committed Dec 14, 2013
1 parent 4a8c457 commit dbbd4b2
Show file tree
Hide file tree
Showing 11 changed files with 191 additions and 189 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Expand Up @@ -2,6 +2,8 @@ src/
lib/
dist/all.min.js
dist/all.min.js.gz
dist/fabric.min.js
dist/fabric.min.js.gz
.DS_Store
HEADER.js
build.js
build.js
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -34,7 +34,7 @@ If you are sure that it's a bug in Fabric.js or a suggestion, open a new [issue]
perfect, but even a simple script demonstrating the error would suffice. You could use [this jsfiddle template](http://jsfiddle.net/fabricjs/Da7SP/) as a
starting point.

- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [all.js file](https://github.com/kangax/fabric.js/blob/master/dist/all.js#L5) or just by executing `fabric.version` in the browser console.
- **Fabric.js version:** Make sure to specify which version of Fabric.js you are using. The version can be found in [fabric.js file](https://github.com/kangax/fabric.js/blob/master/dist/fabric.js#L5) or just by executing `fabric.version` in the browser console.

## Pull requests

Expand Down
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -104,7 +104,7 @@ Fabric.js started as a foundation for design editor on [printio.ru](http://print

If you use google closure compiler you have to add `sourceMappingURL` manually at the end of the minified file all.min.js (see issue https://code.google.com/p/closure-compiler/issues/detail?id=941).

//# sourceMappingURL=all.min.js.map
//# sourceMappingURL=fabric.min.js.map

### Demos

Expand Down Expand Up @@ -137,11 +137,11 @@ These are the optional modules that could be specified for inclusion, when build

Additional flags for build script are:

- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/all.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/all.require.js`
- **requirejs** — Makes fabric requirejs AMD-compatible in `dist/fabric.js`. *Note:* an unminified, requirejs-compatible version is always created in `dist/fabric.require.js`
- **no-strict** — Strips "use strict" directives from source
- **no-svg-export** — Removes svg exporting functionality
- **no-es5-compat** - Removes ES5 compat methods (Array.prototype.*, String.prototype.*, Function.prototype.*)
- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/all.min.js`
- **sourcemap** - Generates a sourceMap file and adds the `sourceMappingURL` (only if uglifyjs is used) to `dist/fabric.min.js`

For example:

Expand All @@ -158,24 +158,24 @@ For example:
</head>
<body>
<canvas id="canvas" width="300" height="300"></canvas>

<script src="lib/fabric.js"></script>
<script>
var canvas = new fabric.Canvas('canvas');
var rect = new fabric.Rect({
top : 100,
left : 100,
width : 60,
height : 70,
fill : 'red'
});
canvas.add(rect);
</script>
</body>
</html>
```
```

### Helping Fabric

Expand Down
32 changes: 16 additions & 16 deletions build.js
Expand Up @@ -43,17 +43,17 @@ if (sourceMap) {
console.log('[notice]: sourceMap support requires uglifyjs or google closure compiler as minifier; changed minifier to uglifyjs.');
minifier = 'uglifyjs';
}
sourceMapFlags = minifier === 'uglifyjs' ? ' --source-map all.min.js.map' : ' --create_source_map all.min.js.map --source_map_format=V3';
sourceMapFlags = minifier === 'uglifyjs' ? ' --source-map fabric.min.js.map' : ' --create_source_map fabric.min.js.map --source_map_format=V3';
}

if (minifier === 'yui') {
mininfierCmd = 'java -jar ' + rootPath + '/lib/yuicompressor-2.4.6.jar all.js -o all.min.js';
mininfierCmd = 'java -jar ' + rootPath + '/lib/yuicompressor-2.4.6.jar fabric.js -o fabric.min.js';
}
else if (minifier === 'closure') {
mininfierCmd = 'java -jar ' + rootPath + '/lib/google_closure_compiler.jar --js all.js --js_output_file all.min.js' + sourceMapFlags;
mininfierCmd = 'java -jar ' + rootPath + '/lib/google_closure_compiler.jar --js fabric.js --js_output_file fabric.min.js' + sourceMapFlags;
}
else if (minifier === 'uglifyjs') {
mininfierCmd = 'uglifyjs ' + amdUglifyFlags + ' --output all.min.js all.js' + sourceMapFlags;
mininfierCmd = 'uglifyjs ' + amdUglifyFlags + ' --output fabric.min.js fabric.js' + sourceMapFlags;
}

var buildSh = 'build-sh' in buildArgsAsObject;
Expand Down Expand Up @@ -285,54 +285,54 @@ else {
process.chdir(distributionPath);

appendFileContents(filesToInclude, function() {
fs.writeFile('all.js', distFileContents, function (err) {
fs.writeFile('fabric.js', distFileContents, function (err) {
if (err) {
console.log(err);
throw err;
}

// add js wrapping in AMD closure for requirejs if necessary
if (amdLib !== false) {
exec('uglifyjs all.js ' + amdUglifyFlags + ' -b --output all.js');
exec('uglifyjs fabric.js ' + amdUglifyFlags + ' -b --output fabric.js');
}

if (amdLib !== false) {
console.log('Built distribution to ' + distributionPath + 'all.js (' + amdLib + '-compatible)');
console.log('Built distribution to ' + distributionPath + 'fabric.js (' + amdLib + '-compatible)');
} else {
console.log('Built distribution to ' + distributionPath + 'all.js');
console.log('Built distribution to ' + distributionPath + 'fabric.js');
}

exec(mininfierCmd, function (error, output) {
if (error) {
console.error('Minification failed using', minifier, 'with', mininfierCmd);
process.exit(1);
}
console.log('Minified using', minifier, 'to ' + distributionPath + 'all.min.js');
console.log('Minified using', minifier, 'to ' + distributionPath + 'fabric.min.js');

if (sourceMapFlags) {
console.log('Built sourceMap to ' + distributionPath + 'all.min.js.map');
console.log('Built sourceMap to ' + distributionPath + 'fabric.min.js.map');
}

exec('gzip -c all.min.js > all.min.js.gz', function (error, output) {
console.log('Gzipped to ' + distributionPath + 'all.min.js.gz');
exec('gzip -c fabric.min.js > fabric.min.js.gz', function (error, output) {
console.log('Gzipped to ' + distributionPath + 'fabric.min.js.gz');
});
});

// Always build requirejs AMD module in all.require.js
// Always build requirejs AMD module in fabric.require.js
// add necessary requirejs footer code to filesToInclude if we haven't before
if (amdLib === false) {
amdLib = "requirejs";
filesToInclude[filesToInclude.length] = ifSpecifiedAMDInclude(amdLib);
}

appendFileContents(filesToInclude, function() {
fs.writeFile('all.require.js', distFileContents, function (err) {
fs.writeFile('fabric.require.js', distFileContents, function (err) {
if (err) {
console.log(err);
throw err;
}
exec('uglifyjs all.require.js ' + amdUglifyFlags + ' -b --output all.require.js');
console.log('Built distribution to ' + distributionPath + 'all.require.js (requirejs-compatible)');
exec('uglifyjs fabric.require.js ' + amdUglifyFlags + ' -b --output fabric.require.js');
console.log('Built distribution to ' + distributionPath + 'fabric.require.js (requirejs-compatible)');
});
});

Expand Down
2 changes: 1 addition & 1 deletion component.json
Expand Up @@ -8,6 +8,6 @@
"development": {},
"license": "MIT",
"scripts": [
"./dist/all.js"
"./dist/fabric.js"
]
}

0 comments on commit dbbd4b2

Please sign in to comment.