Skip to content

Commit f3b6df2

Browse files
committed
Switch build to use browserify (niklasvh#502)
1 parent 60619dc commit f3b6df2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4049
-1239
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "src/fabric"]
22
path = src/fabric
33
url = https://github.com/kangax/fabric.js.git
4-
[submodule "src/punycode"]
5-
path = src/punycode
6-
url = https://github.com/bestiejs/punycode.js.git

.jshintrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@
1515
"globals": {
1616
"jQuery": true
1717
},
18-
"predef": ["NodeParser", "NodeContainer", "Color", "StackingContext", "TextContainer", "PseudoElementContainer", "ImageLoader", "CanvasRenderer", "Renderer", "Support", "bind", "Promise", "getBounds", "offsetBounds", "XHR",
19-
"ImageContainer", "ProxyImageContainer", "DummyImageContainer", "Font", "FontMetrics", "GradientContainer", "LinearGradientContainer", "WebkitGradientContainer", "SVGContainer", "SVGNodeContainer", "FrameContainer", "html2canvas", "log", "smallImage", "parseBackgrounds", "loadUrlDocument", "decode64", "Proxy", "ProxyURL"]
18+
"predef": ["-Promise"]
2019
}

Gruntfile.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ module.exports = function(grunt) {
88
banner: '/*\n <%= pkg.title || pkg.name %> <%= pkg.version %>' +
99
'<%= pkg.homepage ? " <" + pkg.homepage + ">" : "" %>' + '\n' +
1010
' Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
11-
'\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/\n',
12-
pre: '\n(function(window, document, exports, global, define, undefined){\n\n',
13-
post: '\n}).call({}, typeof(window) !== "undefined" ? window : undefined, typeof(document) !== "undefined" ? document : undefined);'
11+
'\n\n Released under <%= _.pluck(pkg.licenses, "type").join(", ") %> License\n*/\n'
1412
};
1513

1614
var browsers = {
@@ -59,16 +57,15 @@ module.exports = function(grunt) {
5957

6058
pkg: grunt.file.readJSON('package.json'),
6159

62-
concat: {
60+
browserify: {
6361
dist: {
64-
src: [
65-
'src/promise.js', 'src/fallback.js', 'src/punycode/punycode.js', 'src/core.js', 'src/*.js', 'src/renderers/*.js'
66-
],
67-
nonull: true,
62+
src: ['src/core.js'],
6863
dest: 'dist/<%= pkg.name %>.js',
69-
options:{
70-
banner: meta.banner + meta.pre,
71-
footer: meta.post
64+
options: {
65+
browserifyOptions: {
66+
standalone: 'html2canvas'
67+
},
68+
banner: meta.banner
7269
}
7370
},
7471
svg: {
@@ -77,8 +74,10 @@ module.exports = function(grunt) {
7774
],
7875
dest: 'dist/<%= pkg.name %>.svg.js',
7976
options:{
80-
banner: meta.banner + '\n(function(window, document, exports, undefined){\n\n',
81-
footer: '\n}).call({}, window, document, html2canvas);'
77+
browserifyOptions: {
78+
standalone: 'html2canvas.svg'
79+
},
80+
banner: meta.banner
8281
}
8382
}
8483
},
@@ -149,11 +148,11 @@ module.exports = function(grunt) {
149148
},
150149
uglify: {
151150
dist: {
152-
src: ['<%= concat.dist.dest %>'],
151+
src: ['<%= browserify.dist.dest %>'],
153152
dest: 'dist/<%= pkg.name %>.min.js'
154153
},
155154
svg: {
156-
src: ['<%= concat.svg.dest %>'],
155+
src: ['<%= browserify.svg.dest %>'],
157156
dest: 'dist/<%= pkg.name %>.svg.min.js'
158157
},
159158
options: {
@@ -165,7 +164,7 @@ module.exports = function(grunt) {
165164
tasks: ['jshint', 'build']
166165
},
167166
jshint: {
168-
all: ['src/*.js', 'src/renderers/*.js', '!src/promise.js'],
167+
all: ['src/*.js', 'src/renderers/*.js'],
169168
options: grunt.file.readJSON('./.jshintrc')
170169
},
171170
mochacli: {
@@ -204,17 +203,17 @@ module.exports = function(grunt) {
204203
});
205204
});
206205

206+
grunt.loadNpmTasks('grunt-browserify');
207207
grunt.loadNpmTasks('grunt-mocha-phantomjs');
208208
grunt.loadNpmTasks('grunt-contrib-watch');
209-
grunt.loadNpmTasks('grunt-contrib-concat');
210209
grunt.loadNpmTasks('grunt-contrib-uglify');
211210
grunt.loadNpmTasks('grunt-contrib-jshint');
212211
grunt.loadNpmTasks('grunt-contrib-connect');
213212
grunt.loadNpmTasks('grunt-execute');
214213
grunt.loadNpmTasks('grunt-mocha-cli');
215214

216215
grunt.registerTask('server', ['connect:cors', 'connect:proxy', 'connect:altServer', 'connect:server']);
217-
grunt.registerTask('build', ['execute', 'concat', 'uglify']);
216+
grunt.registerTask('build', ['execute', 'browserify', 'uglify']);
218217
grunt.registerTask('default', ['jshint', 'build', 'mochacli', 'connect:altServer', 'mocha_phantomjs']);
219218
grunt.registerTask('travis', ['jshint', 'build', 'connect:altServer', 'connect:ci', 'connect:proxy', 'connect:cors', 'mocha_phantomjs', 'webdriver']);
220219

0 commit comments

Comments
 (0)