UNPKG

1.75 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9 */
10
11'use strict';
12
13const compilerPackage = require('google-closure-compiler');
14const gulp = require('gulp');
15const sourcemaps = require('gulp-sourcemaps');
16const rollup = require('rollup-stream');
17const source = require('vinyl-source-stream');
18
19const closureCompiler = compilerPackage.gulp();
20
21gulp.task('default', () => {
22 return gulp.src('./src/**/*.js', {base: './'})
23 .pipe(sourcemaps.init())
24 .pipe(closureCompiler({
25 compilation_level: 'ADVANCED',
26 warning_level: 'VERBOSE',
27 language_in: 'ECMASCRIPT6_STRICT',
28 language_out: 'ECMASCRIPT5_STRICT',
29 externs: ['externs/custom-elements.js'],
30 dependency_mode: 'STRICT',
31 entry_point: ['/src/custom-elements'],
32 js_output_file: 'custom-elements.min.js',
33 output_wrapper: '(function(){\n%output%\n}).call(self);',
34 assume_function_wrapper: true,
35 new_type_inf: true,
36 rewrite_polyfills: false,
37 }))
38 .pipe(sourcemaps.write('/'))
39 .pipe(gulp.dest('./'));
40});
41
42gulp.task('debug', () => {
43 return rollup({
44 entry: './src/custom-elements.js',
45 format: 'iife',
46 sourceMap: false,
47 indent: true,
48 })
49 .pipe(source('custom-elements.min.js'))
50 .pipe(gulp.dest('./'));
51});