Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SoonIter opened this issue Dec 17, 2024 · 1 comment
Open

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

SoonIter opened this issue Dec 17, 2024 · 1 comment
Labels
feat New feature or request team The issue/pr is created by the member of Rspack.

Comments

@SoonIter
Copy link
Member

SoonIter commented Dec 17, 2024

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";

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',
      },
    ]
}
@SoonIter SoonIter added feat New feature or request pending triage The issue/PR is currently untouched. labels Dec 17, 2024
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Dec 17, 2024
@SoonIter
Copy link
Member Author

SoonIter commented Dec 17, 2024

I'm not very clear whether we need to enforce relative path in css, but it works in Rsbuild

Input

// index.css
.a {
  background: url('./assets/react.svg');
}

experimental: css output

.a {
  background: url(static/svg/react.svg);
}

css-extract-rspack-plugin

.a {
  background: url(static/svg/react.svg);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

2 participants