Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 in AOLP_ADS_JS/prebid.js from feature/build-wit…
Browse files Browse the repository at this point in the history
…h-delimiters to master

* commit '3a11e72cf5fc3149ec41b42a8f924ff076556603':
  Removed delimiters around base adapter classes in the build output
  Modified build to include delimiters for adapters
  • Loading branch information
marian-r committed Jul 28, 2016
2 parents 952ce42 + 3a11e72 commit a732dfc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ gulp.task('webpack', function () {
return gulp.src([].concat(analyticsSources, 'src/prebid.js'))
.pipe(webpack(webpackConfig))
.pipe(replace('$prebid.version$', prebid.version))
.pipe(uglify())
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(header(banner, { prebid: prebid }))
.pipe(gulp.dest('build/dist'))
.pipe(connect.reload());
Expand Down
4 changes: 2 additions & 2 deletions loaders/adapterLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function insertAdapters() {
return '';
}

return inserts.map(name => {
return '/*!ADAPTER REGISTER DELIMITER*/' + inserts.map(name => {
if (name === 'appnexusAst') {
return `import { AppnexusAst } from './adapters/appnexusAst';
exports.registerBidAdapter(new AppnexusAst('appnexus'), 'appnexus');\n`;
Expand All @@ -61,7 +61,7 @@ function insertAdapters() {
const name = Object.keys(adapter)[0];
return `exports.aliasBidAdapter('${name}','${adapter[name].alias}');\n`;
}))
.join('');
.join('/*!ADAPTER REGISTER DELIMITER*/');
}

/**
Expand Down
14 changes: 14 additions & 0 deletions loaders/delimiterLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2016 AOL Platforms.

/**
* @author Marian Rusnak <[email protected]>
*/

module.exports = function(content) {
var adapterName = this.resourcePath.slice(this.resourcePath.lastIndexOf('/') + 1, -3);
// Intentionally added 'window=window;' after the comment so it is not removed.
// It is probably a bug in UglifyJS that the comment is not recognized as comment node.
// I will look at it later.
// TODO(marian.rusnak): Investigate and fix Uglify comments recognition and removal.
return `/*!ADAPTER BEGIN ${adapterName}*/window=window;${content}/*!ADAPTER END ${adapterName}*/window=window;`;
};
6 changes: 6 additions & 0 deletions webpack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ module.exports = {
include: /(src)/,
loader: 'adapterLoader'
},
{
test: /adapters/,
include: /(src)/,
exclude: /(adapter.js|baseAdapter.js)/,
loader: 'delimiterLoader'
},
{
test: /constants.json$/,
include: /(src)/,
Expand Down

0 comments on commit a732dfc

Please sign in to comment.