Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Broken async chunk URLs from resetting public path #11

@daun

Description

@daun

Describe the bug
Starting in v0.1.3, this plugin resets the publicPath config key to solve an issue with duplicate slashes. However, this will break loading async chunks in projects that define a custom publicPath and which don't load their assets from the root / but some subfolder like /dist/assets/.

Expected behavior
The plugin shouldn't modify any previously set publicPath.

Suggested fix
I've previously fixed the double-slash issue by adding a manifest transform. Maybe adding this as a default transform makes resetting the public path unnecessary. OTOH, you'd need to be smart about merging the default transform with any user-supplied transform array.

const fixDoubleSlashes = (manifestEntries) => {
  const manifest = manifestEntries.map(entry => {
    entry.url = entry.url.replace('//', '/')
    return entry
  })
  return { manifest, warnings: [] }
}

mix.generateSW({
  manifestTransforms: [fixDoubleSlashes]
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions