Skip to content

Support the webpack publicPath: 'auto' configuration #307

Description

@czerkies

Expected Behavior

Use the "auto" mechanism of webpack publicPath configuration.

Actual Behavior

"auto" as a string is added to asset paths in the manifest.

Additional Information

When I use in production mode, your great plugin for webpack, the "new" way do declare auto in publicPath inside the webpack.config.js, the plugin takes the value as a string.
Maybe a condition could be added to take that special feature.
Thanks!

Activity

  1. shellscape commented on Jun 30, 2025

    @shellscape
    Owner

    PR welcome

  2. charliecreates commented on Oct 30, 2025

    @charliecreates
    Contributor
    Expand this to see my work.
    • Read Issue #307 and reviewed the report that 'auto' from compiler.options.output.publicPath was being emitted literally, clarifying expected behavior.
    • Audited test/unit/paths.ts for publicPath/basePath coverage and confirmed no existing 'auto' case.
    • Identified the correct spot in test/unit/paths.ts to assert that 'auto' should not prefix manifest URLs.
    • Traced how URLs are composed from compiler.options.output.publicPath inside WebpackManifestPlugin to understand current behavior.
    • Added a unit test in test/unit/paths.ts: "does not prefix paths when webpack's publicPath is 'auto'", expecting 'one.js': 'one.<hash>.js' (no 'auto' prefix).
    • Built the project with tsc and ran the suite; vitest summary shows: "✓ test/unit/paths.ts (11 tests)" and overall "45 passed | 5 skipped (50)", confirming the new 'auto' test passes.
    • Cross-checked behavior against webpack docs for Automatic publicPath; current output matches docs (no literal 'auto' in manifest values).
  3. charliecreates commented on Oct 30, 2025

    @charliecreates
    Contributor

    Implemented support for webpack’s automatic publicPath. When output.publicPath is set to 'auto', the plugin now treats it as runtime‑resolved and does not prefix manifest values with the literal string auto.

    Opened PR: #312

    Changes
    • In src/hooks.ts, resolve stats.publicPath/options.publicPath and treat the literal 'auto' as empty so manifest paths are not prefixed.
    • Added a unit test in test/unit/paths.ts to assert that 'auto' does not appear in manifest values.
    Verification
    # Build
    $ pnpm build
    # OK
    
    # Tests (Vitest)
    $ pnpm test
    # Test Files: 12 passed | 4 skipped (16)
    # Tests:      45 passed | 5 skipped (50)
    
    # Lint
    # Skipped (preexisting tool issue with ESLint 9.38 + custom parser serialization).
    # Not related to this change; build and tests pass locally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions