Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: appengine/config_service/ui/bower_components/webcomponentsjs/gulpfile.js

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * @license
3 * Copyright (c) 2017 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 buffer = require('vinyl-buffer');
19 const rename = require('gulp-rename');
20 const rollup = require('rollup-stream');
21 const source = require('vinyl-source-stream');
22 const del = require('del');
23 const bower = require('bower');
24 const runseq = require('run-sequence');
25 const closure = require('google-closure-compiler').gulp();
26 const babel = require('rollup-plugin-babel');
27
28 function debugify(sourceName, fileName, extraRollupOptions) {
29 if (!fileName)
30 fileName = sourceName;
31
32 const options = {
33 entry: `./entrypoints/${sourceName}-index.js`,
34 format: 'iife',
35 moduleName: 'webcomponentsjs'
36 };
37
38 Object.assign(options, extraRollupOptions);
39
40 return rollup(options)
41 .pipe(source(`${sourceName}-index.js`), 'entrypoints')
42 .pipe(rename(fileName + '.js'))
43 .pipe(gulp.dest('./'))
44 }
45
46 function closurify(sourceName, fileName) {
47 if (!fileName) {
48 fileName = sourceName;
49 }
50
51 const closureOptions = {
52 new_type_inf: true,
53 compilation_level: 'ADVANCED',
54 language_in: 'ES6_STRICT',
55 language_out: 'ES5_STRICT',
56 output_wrapper: '(function(){\n%output%\n}).call(self)',
57 assume_function_wrapper: true,
58 js_output_file: `${fileName}.js`,
59 warning_level: 'VERBOSE',
60 rewrite_polyfills: false,
61 externs: [
62 'externs/webcomponents.js',
63 'bower_components/custom-elements/externs/custom-elements.js',
64 'bower_components/html-imports/externs/html-imports.js',
65 'bower_components/shadycss/externs/shadycss-externs.js',
66 'bower_components/shadydom/externs/shadydom.js'
67 ],
68 // entry_point: `/entrypoints/${sourceName}-index.js`,
69 // dependency_mode: 'STRICT'
70 };
71
72 // const closureSources = [
73 // 'src/*.js',
74 // 'entrypoints/*.js',
75 // 'bower_components/custom-elements/src/**/*.js',
76 // 'bower_components/html-imports/src/*.js',
77 // 'bower_components/es6-promise/dist/es6-promise.auto.min.js',
78 // 'bower_components/webcomponents-platform/*.js',
79 // 'bower_components/shadycss/{src,entrypoints}/*.js',
80 // 'bower_components/shadydom/src/*.js',
81 // 'bower_components/template/*.js'
82 // ];
83
84 const rollupOptions = {
85 entry: `entrypoints/${sourceName}-index.js`,
86 format: 'iife',
87 moduleName: 'webcomponents',
88 sourceMap: true,
89 context: 'window'
90 };
91
92 return rollup(rollupOptions)
93 .pipe(source(`${sourceName}-index.js`, 'entrypoints'))
94 .pipe(buffer())
95 .pipe(sourcemaps.init({loadMaps: true}))
96 .pipe(closure(closureOptions))
97 .pipe(sourcemaps.write('.'))
98 .pipe(gulp.dest('.'));
99
100 // return gulp.src(sources, {base: './'})
101 // .pipe(sourcemaps.init({loadMaps: true}))
102 // .pipe(closure(closureOptions))
103 // .pipe(sourcemaps.write('.'))
104 // .pipe(gulp.dest('.'));
105 }
106
107 gulp.task('debugify-hi', () => {
108 return debugify('webcomponents-hi')
109 });
110
111 gulp.task('debugify-hi-ce', () => {
112 return debugify('webcomponents-hi-ce')
113 });
114
115 gulp.task('debugify-hi-sd-ce', () => {
116 return debugify('webcomponents-hi-sd-ce')
117 });
118
119 gulp.task('debugify-hi-sd-ce-pf', () => {
120 // The es6-promise polyfill needs to set the correct context.
121 // See https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
122 const extraOptions = {context: 'window'};
123 return debugify('webcomponents-hi-sd-ce-pf', 'webcomponents-lite', extraOption s)
124 });
125
126 gulp.task('debugify-sd-ce', () => {
127 return debugify('webcomponents-sd-ce')
128 });
129
130 gulp.task('closurify-hi', () => {
131 return closurify('webcomponents-hi')
132 });
133
134 gulp.task('closurify-hi-ce', () => {
135 return closurify('webcomponents-hi-ce')
136 });
137
138 gulp.task('closurify-hi-sd-ce', () => {
139 return closurify('webcomponents-hi-sd-ce')
140 });
141
142 gulp.task('closurify-hi-sd-ce-pf', () => {
143 return closurify('webcomponents-hi-sd-ce-pf', 'webcomponents-lite')
144 });
145
146 gulp.task('closurify-sd-ce', () => {
147 return closurify('webcomponents-sd-ce')
148 });
149
150 function singleLicenseComment() {
151 let hasLicense = false;
152 return (comment) => {
153 if (hasLicense) {
154 return false;
155 }
156 return hasLicense = /@license/.test(comment);
157 }
158 }
159
160 const babelOptions = {
161 presets: 'babili',
162 shouldPrintComment: singleLicenseComment()
163 };
164
165 gulp.task('debugify-ce-es5-adapter', () => {
166 return debugify('custom-elements-es5-adapter', '', {plugins: [babel(babelOptio ns)]});
167 });
168
169 gulp.task('refresh-bower', () => {
170 return del('bower_components').then(() => {
171 let resolve, reject;
172 let p = new Promise((res, rej) => {resolve = res; reject = rej});
173 bower.commands.install().on('end', () => resolve()).on('error', (e) => rejec t(e));
174 return p;
175 });
176 });
177
178 gulp.task('default', (cb) => {
179 runseq('refresh-bower', 'closure', cb);
180 });
181
182 gulp.task('clean-builds', () => {
183 return del(['custom-elements-es5-adapter.js{,.map}', 'webcomponents*.js{,.map} ', '!webcomponents-loader.js']);
184 });
185
186 gulp.task('debug', (cb) => {
187 const tasks = [
188 'debugify-hi',
189 'debugify-hi-ce',
190 'debugify-hi-sd-ce',
191 'debugify-hi-sd-ce-pf',
192 'debugify-sd-ce',
193 'debugify-ce-es5-adapter'
194 ];
195 runseq('clean-builds', tasks, cb);
196 });
197
198 gulp.task('closure', (cb) => {
199 const tasks = [
200 'closurify-hi',
201 'closurify-hi-ce',
202 'closurify-hi-sd-ce',
203 'closurify-hi-sd-ce-pf',
204 'closurify-sd-ce',
205 'debugify-ce-es5-adapter'
206 ];
207 runseq('clean-builds', ...tasks, cb);
208 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698