Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: build/bundled prefix on service worker #2232

Closed
jeffkevin opened this issue Aug 25, 2016 · 6 comments
Closed

Bug: build/bundled prefix on service worker #2232

jeffkevin opened this issue Aug 25, 2016 · 6 comments

Comments

@jeffkevin
Copy link

Description

The bundled and unbundled service worker PrecacheConfig have build/bundled / build/unbundled prefix

Versions & Environment

  • Polymer CLI: 0.16.0
  • node: 6.4.0
  • Operating System: Windows 10

Steps to Reproduce

  1. Create an application project: polymer init custom-build
  2. Build: gulp
  3. Serve: polymer serve build/bundled

Expected Results

Service worker will work.

Actual Results

Service worker throws a lot of 404, due to the prefix build/bundled that was added to the service-worker.js

Current Fix

After build edit service-worker.js inside the build directories (@line:32) and remove the prefix there.

From:

var PrecacheConfig = [["build/bundled/index.html","e72684107df02cd146c2ece478b52e20"],
["build/bundled/src/my-app.html","708a8fdc577d21529d5b3edffa1f0e46"],
["build/bundled/src/my-view1.html","b5faca894bd7d36cd63a16d72736cf87"],
["build/bundled/src/my-view2.html","e592b7008d376dd87df1013fa9208aca"],
["build/bundled/src/my-view3.html","a149b68afc85efa2a8b17476c809f027"],
["build/bundled/src/my-view404.html","b9a28746f736435f74b42f65b65b4eac"]];

To:

var PrecacheConfig = [["/index.html","e72684107df02cd146c2ece478b52e20"],
["/src/my-app.html","708a8fdc577d21529d5b3edffa1f0e46"],
["/src/my-view1.html","b5faca894bd7d36cd63a16d72736cf87"],
["/src/my-view2.html","e592b7008d376dd87df1013fa9208aca"],
["/src/my-view3.html","a149b68afc85efa2a8b17476c809f027"],
["/src/my-view404.html","b9a28746f736435f74b42f65b65b4eac"]];

same goes to unbundled directory, after changing them the 404 issues are gone.

@jeffkevin jeffkevin changed the title build/bundled prefix on service worker Bug: build/bundled prefix on service worker Aug 25, 2016
@FredKSchott
Copy link
Contributor

Sorry I just tried your repro steps and can't reproduce (everything looked fine). This was fixed in an earlier version of polymer-cli/polymer-build, you may want to try a clean reinstallation of both.

@jeffkevin
Copy link
Author

I tried to install freshly both

  • polymer-cli
  • generator-polymer-init-custom-build

but the result is the same.
sometimes there are no errors when served because of the cache of the other polymer-kits.
please note that this issue occurs only to the custom-build, the other starter kits build fine.

@eeid26
Copy link

eeid26 commented Aug 30, 2016

yes, I noticed there is a bug in the custom build script (gulp-tasks/project.js) if you are building on windows.
You can fix it by adding bundledPath.replace('', '/') and unbundledPath.replace('', '/'),

Here is the full code with the fix

// Returns a Promise to generate a service worker for bundled output
function writeBundledServiceWorker() {
  // On windows if we pass the path with back slashes the sw-precache node module is not going
  // to strip the build/bundled or build/unbundled because the path was passed in with backslash.
  return polymer.addServiceWorker({
    project: project,
    buildRoot: bundledPath.replace('\\', '/'),
    swConfig: global.config.swPrecacheConfig,
    serviceWorkerPath: global.config.serviceWorkerPath,
    bundled: true
  });
}

// Returns a Promise to generate a service worker for unbundled output
function writeUnbundledServiceWorker() {
  return polymer.addServiceWorker({
    project: project,
    buildRoot: unbundledPath.replace('\\', '/'),
    swConfig: global.config.swPrecacheConfig,
    serviceWorkerPath: global.config.serviceWorkerPath
  });
}

@jeffkevin
Copy link
Author

Thank you for this

@FredKSchott
Copy link
Contributor

@FredKSchott
Copy link
Contributor

@aomarks aomarks transferred this issue from Polymer/polymer-cli Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants