Skip to content

Commit 435a91a

Browse files
committed
Each dist/plugin has unique UMD header (e.g. Raven.AngularPlugin)
1 parent 441a239 commit 435a91a

File tree

1 file changed

+61
-48
lines changed

1 file changed

+61
-48
lines changed

Gruntfile.js

+61-48
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = function(grunt) {
8282

8383
var file = {};
8484
file.src = plugin;
85-
file.dest = path.join('build', 'plugin', filename);
85+
file.dest = path.join('build', 'plugins', filename);
8686

8787
return file;
8888
});
@@ -100,58 +100,71 @@ module.exports = function(grunt) {
100100
return dict;
101101
}, {});
102102

103-
var gruntConfig = {
104-
pkg: grunt.file.readJSON('package.json'),
105-
aws: grunt.file.exists('aws.json') ? grunt.file.readJSON('aws.json'): {},
106-
107-
clean: ['build'],
108-
109-
browserify: {
110-
options: {
111-
banner: grunt.file.read('template/_copyright.js'),
103+
var browserifyConfig = {
104+
options: {
105+
banner: grunt.file.read('template/_copyright.js'),
112106
browserifyOptions: {
113-
standalone: 'Raven' // umd
114-
115-
},
116-
transform: [versionify],
117-
plugin: [ derequire ]
118-
},
119-
core: {
120-
src: 'src/singleton.js',
121-
dest: 'build/raven.js'
107+
standalone: 'Raven' // umd
122108
},
123-
plugins: {
124-
files: pluginSingleFiles,
125-
options: {
126-
external: [
127-
'../src/singleton'
128-
],
129-
transform: [
130-
[ versionify ],
131-
[ new AddPluginBrowserifyTransformer() ]
132-
]
133-
}
134-
},
135-
'plugins-combined': {
136-
files: pluginConcatFiles,
109+
transform: [ versionify ],
110+
plugin: [ derequire ]
111+
},
112+
core: {
113+
src: 'src/singleton.js',
114+
dest: 'build/raven.js'
115+
},
116+
'plugins-combined': {
117+
files: pluginConcatFiles,
137118
options: {
138-
transform: [
139-
[ versionify ],
140-
[ new AddPluginBrowserifyTransformer() ]
141-
]
142-
}
143-
},
144-
test: {
145-
src: 'test/**/*.test.js',
119+
transform: [
120+
[ versionify ],
121+
[ new AddPluginBrowserifyTransformer() ]
122+
]
123+
}
124+
},
125+
test: {
126+
src: 'test/**/*.test.js',
146127
dest: 'build/raven.test.js',
147128
options: {
148-
browserifyOptions: {
149-
debug: true // source maps
150-
},
151-
plugin: [proxyquire.plugin]
129+
browserifyOptions: {
130+
debug: true // source maps
131+
},
132+
plugin: [proxyquire.plugin]
133+
}
134+
}
135+
};
136+
137+
// Create a dedicated entry in browserify config for
138+
// each individual plugin (each needs a unique `standalone`
139+
// config)
140+
var browserifyPluginTaskNames = [];
141+
pluginSingleFiles.forEach(function (item) {
142+
var name = item.src
143+
.replace(/.*\//, '') // everything before slash
144+
.replace('.js', ''); // extension
145+
var capsName = name.charAt(0).toUpperCase() + name.slice(1);
146+
var config = {
147+
src: item.src,
148+
dest: item.dest,
149+
options: {
150+
browserifyOptions: {
151+
// e.g. Raven.AngularPlugin
152+
standalone: 'Raven.' + capsName + 'Plugin'
152153
}
153154
}
154-
},
155+
};
156+
browserifyConfig[name] = config;
157+
browserifyPluginTaskNames.push('browserify:' + name);
158+
});
159+
160+
161+
var gruntConfig = {
162+
pkg: grunt.file.readJSON('package.json'),
163+
aws: grunt.file.exists('aws.json') ? grunt.file.readJSON('aws.json'): {},
164+
165+
clean: ['build'],
166+
167+
browserify: browserifyConfig,
155168

156169
uglify: {
157170
options: {
@@ -258,7 +271,7 @@ module.exports = function(grunt) {
258271
copy: {
259272
dist: {
260273
expand: true,
261-
flatten: true,
274+
flatten: false,
262275
cwd: 'build/',
263276
src: '**',
264277
dest: 'dist/'
@@ -344,7 +357,7 @@ module.exports = function(grunt) {
344357
// Build tasks
345358
grunt.registerTask('_prep', ['clean', 'gitinfo', 'version']);
346359
grunt.registerTask('browserify.core', ['_prep', 'browserify:core']);
347-
grunt.registerTask('browserify.plugins', ['_prep', 'browserify:plugins']);
360+
grunt.registerTask('browserify.plugins', ['_prep'].concat(browserifyPluginTaskNames));
348361
grunt.registerTask('browserify.plugins-combined', ['_prep', 'browserify:plugins-combined']);
349362
grunt.registerTask('build.test', ['_prep', 'browserify:test']);
350363
grunt.registerTask('build.core', ['browserify.core', 'uglify', 'fixSourceMaps', 'sri:dist']);

0 commit comments

Comments
 (0)