Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Include unbundled build in gulpfile #56

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions generators/app/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const swPrecacheConfig = require('./sw-precache-config.js');
const polymerJson = require('./polymer.json');
const polymerProject = new polymerBuild.PolymerProject(polymerJson);
const buildDirectory = 'build';
const bundledDirectory = buildDirectory + '/bundled';
const unbundledDirectory = buildDirectory + '/unbundled';

/**
* Waits for the given ReadableStream
Expand Down Expand Up @@ -63,23 +65,36 @@ function build() {
console.log('Analyzing build dependencies...');
});

// If you want bundling, pass the stream to polymerProject.bundler.
// Pipe the unbundled build to the unbundled directory
buildStream = buildStream.pipe(gulp.dest(unbundledDirectory));

// Pass the stream to polymerProject.bundler.
// This will bundle dependencies into your fragments so you can lazy
// load them.
buildStream = buildStream.pipe(polymerProject.bundler);

// Okay, time to pipe to the build directory
buildStream = buildStream.pipe(gulp.dest(buildDirectory));
// Okay, time to pipe to bundled build the bundled directory
buildStream = buildStream.pipe(gulp.dest(bundledDirectory));

// waitFor the buildStream to complete
return waitFor(buildStream);
})
.then(() => {
// Okay, now let's generate the Service Worker
console.log('Generating the Service Worker...');
// Okay, now let's generate the unbundled Service Worker
console.log(`Generating the ${unbundledDirectory} Service Worker...`);
return polymerBuild.addServiceWorker({
project: polymerProject,
buildRoot: unbundledDirectory,
bundled: false,
swPrecacheConfig: swPrecacheConfig
});
})
.then(() => {
// Okay, now let's generate the bundled Service Worker
console.log(`Generating the ${bundledDirectory} Service Worker...`);
return polymerBuild.addServiceWorker({
project: polymerProject,
buildRoot: buildDirectory,
buildRoot: bundledDirectory,
bundled: true,
swPrecacheConfig: swPrecacheConfig
});
Expand Down