Skip to content

Commit 4f63898

Browse files
authored
workbox to 5.0.0, inline (GoogleChrome#2246)
* workbox to 5.0.0, inline * review feedback * add TODO
1 parent 6f2d8e9 commit 4f63898

File tree

4 files changed

+2569
-184
lines changed

4 files changed

+2569
-184
lines changed

build.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const log = require("fancy-log");
2323
const rollupPluginNodeResolve = require("rollup-plugin-node-resolve");
2424
const rollupPluginCJS = require("rollup-plugin-commonjs");
2525
const rollupPluginVirtual = require("rollup-plugin-virtual");
26+
const rollupPluginReplace = require("rollup-plugin-replace");
2627
const rollup = require("rollup");
2728
const terser = isProd ? require("terser") : null;
2829
const {getManifest} = require("workbox-build");
@@ -123,6 +124,12 @@ async function build() {
123124
const swBundle = await rollup.rollup({
124125
input: "src/lib/sw.js",
125126
plugins: [
127+
// Workbox uses a variable known to be undefined (!) and forces this plugin to be used.
128+
// TODO(samthor): This generates statements like "if (1 !== 1)", which are NOT removed from
129+
// the final bundle code. Terser/Rollup don't strip them.
130+
rollupPluginReplace({
131+
"process.env.NODE_ENV": JSON.stringify("production"),
132+
}),
126133
rollupPluginVirtual({
127134
"cache-manifest": `export default ${JSON.stringify(
128135
manifest,

0 commit comments

Comments
 (0)