1

Let's say I have a root or base url of aws.com/prefix/. I want to run the PWA (vue init pwa my-vue-app) at this url, but the PWA by default serves at /. I was able to change the assets path in various configurations for css, js, and the index.html, but the service-worker.js file in dist seems to only load at /.

Is there a parameter somewhere to allow a different base or root url for service-worker in the Vue / Vuex PWA project?

The available config files that might have options for this are:

build/service-worker-prod.js
build/webpack.base.conf.js
build/webpack.prod.conf.js
config/index.js
1
  • I changed the following line in build/service-worker-prod.js, navigator.serviceWorker.register('PREFIX_HERE/service-worker.js') To fix the issue, but this seems a bit hacky, wondering if there is a proper configuration location to change this. Commented Oct 22, 2018 at 21:44

1 Answer 1

2

The solution is to add a element to the index.html such as:

<base href="<%= htmlWebpackPlugin.files.publicPath %>">

Then it will use the webpack publicPath, which is a redirect to the index.js assetsPath value.

The service-worker will adopt this base path.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.