Skip to content

Instantly share code, notes, and snippets.

@samthor
Last active October 17, 2016 08:47
Show Gist options
  • Save samthor/b331861b0e1e043ca9ab4b861db87d53 to your computer and use it in GitHub Desktop.
Save samthor/b331861b0e1e043ca9ab4b861db87d53 to your computer and use it in GitHub Desktop.
Polymer/Closure: Step #2, Compile
const closure = require('google-closure-compiler-js').gulp();
const fs = require('fs');
gulp.task('compile', ['merge'], function() {
// nb. This is a bit awkward, but we need to load the Polymer externs so that
// Closure can compile Polymer code correctly.
const externsPath =
'node_modules/google-closure-compiler-js/contrib/externs/polymer-1.0.js';
const externsSrc = fs.readFileSync(externsPath, 'utf-8');
return gulp.src('dest/elements.js')
.pipe(closure({
polymerPass: true, // !! IMPORTANT !!
externs: [
{'src': externsSrc, 'path': 'polymer-1.0.js'}
],
compilationLevel: 'SIMPLE',
warningLevel: 'VERBOSE',
jsOutputFile: 'elements.min.js',
createSourceMap: true,
}))
.pipe(gulp.dest('dest'));
});
@samthor
Copy link
Author

samthor commented Oct 17, 2016

Note that this requires Step #1 to work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment