| OLD | NEW |
| (Empty) | |
| 1 /** |
| 2 * @license |
| 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
| 4 * This code may only be used under the BSD style license found at http://polyme
r.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/CON
TRIBUTORS.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/PA
TENTS.txt |
| 9 */ |
| 10 |
| 11 'use strict'; |
| 12 |
| 13 /* eslint-env node */ |
| 14 /* eslint-disable no-console */ |
| 15 |
| 16 const gulp = require('gulp'); |
| 17 const sourcemaps = require('gulp-sourcemaps'); |
| 18 const del = require('del'); |
| 19 const rename = require('gulp-rename'); |
| 20 const rollup = require('rollup-stream'); |
| 21 const buffer = require('vinyl-buffer'); |
| 22 const source = require('vinyl-source-stream'); |
| 23 const closure = require('google-closure-compiler').gulp(); |
| 24 const size = require('gulp-size'); |
| 25 const runseq = require('run-sequence'); |
| 26 |
| 27 const modules = [ |
| 28 'css-parse', |
| 29 'custom-style-element', |
| 30 'make-element', |
| 31 'svg-in-shadow', |
| 32 'style-util', |
| 33 'style-transformer', |
| 34 'style-settings' |
| 35 ]; |
| 36 |
| 37 const moduleTasks = modules.map((m) => { |
| 38 gulp.task(`test-module-${m}`, () => { |
| 39 return rollup({ |
| 40 entry: `tests/module/${m}.js`, |
| 41 format: 'iife', |
| 42 moduleName: m |
| 43 }) |
| 44 .pipe(source(`${m}.js`, 'tests/module')) |
| 45 .pipe(gulp.dest('./tests/module/generated')) |
| 46 }); |
| 47 return `test-module-${m}`; |
| 48 }); |
| 49 |
| 50 gulp.task('clean-test-modules', () => del(['tests/module/generated'])); |
| 51 |
| 52 gulp.task('test-modules', (cb) => { |
| 53 runseq('clean-test-modules', moduleTasks, cb); |
| 54 }); |
| 55 |
| 56 function closurify(entry) { |
| 57 gulp.task(`closure-${entry}`, () => { |
| 58 return gulp.src(['src/*.js', 'entrypoints/*.js'], {base: './'}) |
| 59 .pipe(sourcemaps.init()) |
| 60 .pipe(closure({ |
| 61 new_type_inf: true, |
| 62 compilation_level: 'ADVANCED', |
| 63 language_in: 'ES6_STRICT', |
| 64 language_out: 'ES5_STRICT', |
| 65 isolation_mode: 'IIFE', |
| 66 assume_function_wrapper: true, |
| 67 js_output_file: `${entry}.min.js`, |
| 68 entry_point: `./entrypoints/${entry}.js`, |
| 69 dependency_mode: 'STRICT', |
| 70 warning_level: 'VERBOSE', |
| 71 rewrite_polyfills: false, |
| 72 externs: 'externs/shadycss-externs.js' |
| 73 })) |
| 74 .pipe(size({showFiles: true, showTotal: false, gzip: true})) |
| 75 .pipe(sourcemaps.write('.')) |
| 76 .pipe(gulp.dest('.')) |
| 77 }); |
| 78 return `closure-${entry}`; |
| 79 } |
| 80 |
| 81 function debugify(entry) { |
| 82 gulp.task(`debug-${entry}`, () => { |
| 83 return rollup({ |
| 84 entry: `entrypoints/${entry}.js`, |
| 85 format: 'iife', |
| 86 moduleName: '${entry}', |
| 87 }) |
| 88 .pipe(source(`${entry}.js`, 'entrypoints')) |
| 89 .pipe(buffer()) |
| 90 .pipe(sourcemaps.init({loadMaps: true})) |
| 91 .pipe(rename(`${entry}.min.js`)) |
| 92 .pipe(size({showFiles: true, showTotal: false, gzip: true})) |
| 93 .pipe(gulp.dest('./')) |
| 94 }); |
| 95 return `debug-${entry}`; |
| 96 } |
| 97 |
| 98 const entrypoints = [ |
| 99 'scoping-shim', |
| 100 'apply-shim', |
| 101 'custom-style-interface' |
| 102 ] |
| 103 |
| 104 let closureTasks = entrypoints.map((e) => closurify(e)); |
| 105 let debugTasks = entrypoints.map((e) => debugify(e)); |
| 106 |
| 107 gulp.task('default', ['closure', 'test-modules']); |
| 108 |
| 109 gulp.task('closure', (cb) => { |
| 110 runseq.apply(null, closureTasks.concat(cb)) |
| 111 }); |
| 112 |
| 113 gulp.task('debug', debugTasks); |
| OLD | NEW |