roxiness / routify-starter

https://example.routify.dev/
198 stars 55 forks source link

ASK - How to use a prefix on the assets and dist files? #100

Closed lamualfa closed 3 years ago

lamualfa commented 3 years ago

For some reason, i can't use the root path as the public URL to deliver the Routify assets. I need to give a prefix URL to each of the Routify assets. I have tried to change some config in assets/__app.html file. But, the new configuration only work in build mode (production), and not working in development mode using Rollup or Nollup (i think because the both of them has their own servers).

How do i solve this problem?

Default structure

assets/__app.html

<link rel="manifest" href="/manifest.json">
<link rel='stylesheet' href='/build/bundle.css'>
<link rel="modulepreload" href="/build/main.js" />

<script type="module" src="/build/main.js"></script>

URL

Server

app.use(express.static('dist'))
app.get('*', handleSsr)

Modified structure

assets/__app.html

<link rel="manifest" href="/public/manifest.json">
<link rel='stylesheet' href='/public/build/bundle.css'>
<link rel="modulepreload" href="/public/build/main.js" />

<script type="module" src="/public/build/main.js"></script>

URL

Server

app.use('/public', express.static('dist'))
app.get('*', handleSsr)
jakobrosenberg commented 3 years ago

I'm not sure I fully understand the issue, but would this fix it?

app.use(express.static('dist'))
app.use(express.static('assets'))