saqirmdev
saqirmdev

Reputation: 85

Webpack + ENV - Cloudflare pages can't load chunks with async import (Wrong URL)

I have a trouble with webpack and Cloudflare pages.

Origin: develop.kop-dev.pages.dev

When loading dynamically modules in typescript using Webpack there is a problem, it loads from incorrect origin. Everything loads (Static imports, Assets etc…) But dynamic import:

const { getSpellName, getSpellDescription } = await import('./KoP_Locale/abilites');

Resolve URL

For some reason it is resolving with wrong URL. It should be develop.kop-dev.pages.dev/...

It was working well before i added .env to client-side (dotenv-webpack). I am not using process.env in any of the await import.

anyway, process.env works because my statics and assets loads correctly where i am using process.env...

Do you know what can be possibly wrong or what I am doing wrong? This is not an issue on my local.

Upvotes: 1

Views: 366

Answers (1)

saqirmdev
saqirmdev

Reputation: 85

I found a solution. Webpack had a missing publicPath option.

Upvotes: 1

Related Questions