1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | const compilerPackage = require('google-closure-compiler');
|
14 | const gulp = require('gulp');
|
15 | const sourcemaps = require('gulp-sourcemaps');
|
16 | const rollup = require('rollup-stream');
|
17 | const source = require('vinyl-source-stream');
|
18 |
|
19 | const closureCompiler = compilerPackage.gulp();
|
20 |
|
21 | gulp.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 |
|
42 | gulp.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 | });
|