This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 309
/
Copy pathgulpfile.js
96 lines (86 loc) · 3 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* @license
* Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var concat = require('gulp-concat');
var frameScript = require('./tools/frame-script');
var gulp = require('gulp');
var insert = require("gulp-insert");
var source = require('vinyl-source-stream');
var symlink = require('gulp-symlink');
// make files available at bower_components/polymer-designer/... so that
// relative html imports work when loaded from disk
gulp.task('symlink', () => {
gulp.src('.').pipe(symlink('bower_components/polymer-designer', {
force: true,
}));
});
// builds the JS bundle that's injected into the editor iframe
gulp.task('frame-script', () => {
gulp.src(frameScript.dependencies)
.pipe(concat('frame.js'))
.pipe(insert.prepend(frameScript.preamble))
.pipe(insert.append(frameScript.postamble))
.pipe(gulp.dest('./elements/designer-document/'));
});
gulp.task('browserify-css', () => {
browserify({
entries: './node_modules/css',
standalone: 'css',
}).bundle()
.pipe(source('css.js'))
.pipe(buffer())
.pipe(gulp.dest('./vendor'));
});
gulp.task('browserify-dom5', ['browserify-parse5'], () => {
var b = browserify({
entries: './node_modules/dom5',
standalone: 'dom5',
});
b.external('vendor/parse5.js');
b.bundle()
.pipe(source('dom5.js'))
.pipe(buffer())
.pipe(gulp.dest('./vendor'));
});
gulp.task('browserify-parse5', () => {
browserify({
entries: './node_modules/parse5',
standalone: 'parse5',
}).bundle()
.pipe(source('parse5.js'))
.pipe(buffer())
.pipe(gulp.dest('./vendor'));
});
gulp.task('browserify-hydrolysis', ['browserify-dom5'], () => {
var b = browserify({
entries: './node_modules/hydrolysis',
standalone: 'hydrolysis',
});
b.external('vendor/dom5.js');
b.bundle()
.pipe(source('hydrolysis.js'))
.pipe(buffer())
.pipe(gulp.dest('./vendor'));
});
gulp.task('browserify', [
'browserify-css',
'browserify-dom5',
'browserify-hydrolysis']);
gulp.task('browser', ['browserify'], () => {
// symlink src/hydrolysis-browser.html to vendor/hydrolysis.html
gulp.src('src/hydrolysis/hydrolysis-browser.html')
.pipe(symlink('vendor/hydrolysis.html', {force: true}));
});
gulp.task('electron', ['frame-script', 'symlink', 'browserify'], () => {
// symlink src/hydrolysis-electron.html to vendor/hydrolysis.html
gulp.src('src/hydrolysis/hydrolysis-electron.html')
.pipe(symlink('vendor/hydrolysis.html', {force: true}));
});