diff --git a/packages/core/types.d.ts b/packages/core/types.d.ts index c6449c7941..f1dc715965 100644 --- a/packages/core/types.d.ts +++ b/packages/core/types.d.ts @@ -184,10 +184,33 @@ declare module '*?inline' { export default content; } +/** + * Raw css + */ declare module '*.css?raw' { const content: string; export default content; } +declare module '*.scss?raw' { + const content: string; + export default content; +} +declare module '*.sass?raw' { + const content: string; + export default content; +} +declare module '*.less?raw' { + const content: string; + export default content; +} +declare module '*.styl?raw' { + const content: string; + export default content; +} +declare module '*.stylus?raw' { + const content: string; + export default content; +} /** * CSS Modules diff --git a/website/docs/en/guide/basic/css-usage.mdx b/website/docs/en/guide/basic/css-usage.mdx index 3121744eaf..22d3ac5a2f 100644 --- a/website/docs/en/guide/basic/css-usage.mdx +++ b/website/docs/en/guide/basic/css-usage.mdx @@ -172,3 +172,7 @@ Using `import "*.css?raw"` has the following behaviors: - Get the raw text content of the CSS file, without any preprocessing or compilation - The content of the CSS file will be inlined into the final JavaScript bundle - No separate CSS file will be generated + +:::tip +Rsbuild's Sass, Less, and Stylus plugins also support the `?raw` query parameter. +::: diff --git a/website/docs/zh/guide/basic/css-usage.mdx b/website/docs/zh/guide/basic/css-usage.mdx index f195832e8c..682d0b4f9b 100644 --- a/website/docs/zh/guide/basic/css-usage.mdx +++ b/website/docs/zh/guide/basic/css-usage.mdx @@ -172,3 +172,7 @@ console.log(rawCss); // 输出 CSS 文件的原始内容 - 获取 CSS 文件的原始文本内容,不经过任何预处理或编译 - 内容会作为字符串内联到最终的 JavaScript 包中 - 不会生成单独的 CSS 文件 + +:::tip +Rsbuild 的 Sass、Less 和 Stylus 插件也支持 `?raw` 查询参数。 +:::