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

Bun.build & Bun.Transpiler CSSStyleSheet 样式表相关的问题 #15310

Open
vamsaya opened this issue Nov 21, 2024 · 0 comments
Open

Bun.build & Bun.Transpiler CSSStyleSheet 样式表相关的问题 #15310

vamsaya opened this issue Nov 21, 2024 · 0 comments
Labels
css CSS parser, bundler-related enhancement New feature or request

Comments

@vamsaya
Copy link

vamsaya commented Nov 21, 2024

js now supports importing css modules, the type is CSSStyleSheet, refer to the documentation.
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import

demo.js

import reset from './reset.css' with { type: 'css' };
document.adoptedStyleSheets = [reset];

Unfortunately, Bun.build doesn't support this, and my suggestion is like this:

Bun.build({
    loader: {
        ".css": "CSSStyleSheet",
    },
    naming: {
        CSSStyleSheet: "/css/[name].css",
    }
});

demo.js

import reset from '/css/reset.css' with { type: 'css' };
document.adoptedStyleSheets = [reset];

Bun.Transpiler with similar functionality to Bun.build removes with { type: 'css' };, please improve it, 3Q

@vamsaya vamsaya added bug Something isn't working needs triage labels Nov 21, 2024
@RiskyMH RiskyMH added enhancement New feature or request css CSS parser, bundler-related and removed bug Something isn't working needs triage labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css CSS parser, bundler-related enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants