lukeed / pwa

(WIP) Universal PWA Builder

Home Page:https://pwa.cafe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export to relative paths?

tiptronic opened this issue Β· comments

Right now pwa export exports to an absolute path (root). Which config do I need to generate relative paths?

You should be able to just do --dest <target> on either your build or export commands.

$ pwa export --dest foobar

# => foobar/index.html
# => foobar/about/index.html
# => etc

Did you try?
I tried
$ pwa export --dest .
and it deleted the whole project 😱

Also: the paths generated are not relative.... they always point to the absolute path (starting with a '/')
<link rel="shortcut icon" href="/assets/favicon.png" /> <link rel="manifest" href="/assets/manifest.json" /> <link href="/bundle.7c264.css" rel="stylesheet" />

Ah, I misunderstood you – sorry. The --dest flag changes where the build files are placed. It also clears the existing/previous files to ensure it's a clean build. I hope you were able to recover your files!

As for relative pathing, that's controlled by webpack's output.publicPath config. It is / by default (in both PWA and webpack).

To change it, you do this:

// pwa.config.js
exports.webpack = function (config) {
  config.output.publicPath = './'; // or whatever you want
}

That will update all the webpack-controlled asset pathing.

In the snippet you pasted above, that means that (only) /bundle.7c264.css will become ./bundle.7c264.css.

To change the /assets/favicon.png and /assets/manifest.json you have to manually change those in your src/index.html – which PWA scaffolded for you during init phase.


I've tested the above config & made the changes to src/index.html's meta tags. All works as you've requested.

You do not need the --dest flag – sorry for misunderstanding the question initially.

Hope that helps!

hi luke,
thx for the great feedback... After deleting my project folder, I understood we're talking about 2 different things 😊 (sorry about me being unclear πŸ™„ )
I will check out your hints asap (not today, as it's pretty late here)...
Maybe you want to add some of these hints to your readme. Or - even better IMO - put a 'pwa.config.js' file into the repo, so people (like me) get a hint, there are options....
Anyway - I appreciate your responsiveness pretty much and I'm looking forward how things work out...
Thx again!!

I think it was mostly my fault, not to worry!

I'm trying to set aside some time to do another sprint of PWA changes. It hasn't been super high on my list lately, simply because it works reliably for my needs now. ...But I definitely need to make sure the documentation is up to par & that the tools that others use are supported.