web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.19k stars 108 forks source link

[Bug]: 最新版本内部使用 rsbuild@0.7.0 之后,自定义 lessOptions 无法生效 #1144

Closed soulwu closed 3 weeks ago

soulwu commented 3 weeks ago

版本信息

System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 122.73 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 125.0.6422.113
    Safari: 17.2.1
  npmPackages:
    rspress: ^1.23.0 => 1.23.0

问题详情

rsbuild 从 0.7.0 版本开始不再内置 less-loader,改为使用 plugin 方式。rspress 新版本也跟进了这一改动,但是新的方式不再支持用户自定义配置 lessOptions。由于 rspress 内部默认加载了 @rsbuild/plugin-less,因此用户也无法自行加载该插件

复现链接

复现步骤

无法配置 lessOptions,比如 lessOptions: { javascriptEnabled: true, math: 'always' }

Timeless0911 commented 3 weeks ago

You can modify the plugins in builderConfig. The built-in plugins for less and sass will be removed in Rspress 2.0 in the future.

soulwu commented 3 weeks ago

You can modify the plugins in builderConfig. The built-in plugins for less and sass will be removed in Rspress 2.0 in the future.

https://codesandbox.io/p/devbox/bold-cdn-wpryxf?file=%2Fpackage.json%3A18%2C1

I modify the plugins, but not take effect at all. I hope the .math class can be width: 1px

Timeless0911 commented 3 weeks ago

Rsbuild may can not modify plugins funtionally like raw or tools.rspack to remove the less plugins built-in and config new less plugins with some options.

You can config via builderConfig.tools.rspack to modify rspack config directly.

Any other good idea? @chenjiahan

chenjiahan commented 3 weeks ago

@Timeless0911 Rspress can check if user is configuring the Less/Sass plugin via builderPlugins or builderConfig.plugins. If configured, Rspress should not register these plugins again.