Skip to content

[Feature]: Support publicPath: auto in asset module #8748

@SoonIter

Description

@SoonIter

What problem does this feature solve?

https://github.com/SoonIter/rspack-asset-module-publicPath-auto

input

// src/index.ts
import x from './assets/react.svg';

expected output

rspack-dist/index.js
rspack-dist/static/svg/react.svg

module.exports = "./static/svg/react.svg";

actual output

rspack-dist/index.js
rspack-dist/static/svg/react.svg

module.exports = "../../static/svg/react.svg";

😭 the auto public path is based on static/svg/react.svg not index.js

webpack output

module.exports = "autostatic/svg/react.svg";

😂 This feature is not supported in Webpack currently

What does the proposed API of configuration look like?

module: {
    generator: {
      asset: {
        publicPath: 'auto'
      }
    },
    rules: [
      {
        test: /\.svg$/,
        type: 'asset',
      },
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featNew feature or requeststaleteamThe issue/pr is created by the member of Rspack.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions