Last active
October 17, 2016 08:47
-
-
Save samthor/b331861b0e1e043ca9ab4b861db87d53 to your computer and use it in GitHub Desktop.
Polymer/Closure: Step #2, Compile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this requires Step #1 to work correctly.