@pisell/rsbuild-plugin-lowcode
Advanced tools
+4
-4
| { | ||
| "name": "@pisell/rsbuild-plugin-lowcode", | ||
| "version": "0.0.5", | ||
| "version": "0.0.6", | ||
| "description": "Rsbuild plugin for low-code material development and build workflows.", | ||
@@ -16,5 +16,2 @@ "main": "index.js", | ||
| ], | ||
| "scripts": { | ||
| "test": "echo \"No tests configured yet.\"" | ||
| }, | ||
| "keywords": [ | ||
@@ -41,3 +38,6 @@ "rsbuild", | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
| "test": "echo \"No tests configured yet.\"" | ||
| } | ||
| } |
+34
-0
@@ -39,2 +39,36 @@ # @pisell/rsbuild-plugin-lowcode | ||
| ### 自定义 PostCSS | ||
| 插件默认会为样式添加 `#body` 选择器前缀。若需要自行控制 PostCSS 插件列表,可以传入 `tools.postcss`: | ||
| ```js | ||
| import addRootSelector from 'postcss-add-root-selector'; | ||
| export default defineConfig({ | ||
| plugins: [ | ||
| pluginLowcode({ | ||
| tools: { | ||
| postcss: (_, { addPlugins }) => { | ||
| addPlugins([ | ||
| { | ||
| postcssPlugin: 'lowcode-root-selector', | ||
| Once(root, helpers) { | ||
| const from = root.source?.input?.file || helpers.result?.opts?.from || ''; | ||
| if (/pisell-materials\.tw\.css$/.test(from)) { | ||
| return; | ||
| } | ||
| const plugin = addRootSelector({ | ||
| rootSelector: '#body', | ||
| }); | ||
| return plugin.Once?.(root, helpers); | ||
| }, | ||
| }, | ||
| ]); | ||
| }, | ||
| }, | ||
| }), | ||
| ], | ||
| }); | ||
| ``` | ||
| ## Alt 调试模式 | ||
@@ -41,0 +75,0 @@ |
+13
-3
@@ -37,5 +37,7 @@ 'use strict'; | ||
| /** | ||
| * 顶层共享 PostCSS 配置(cascade 到所有 environments)。 | ||
| * 默认 PostCSS 配置(cascade 到所有 environments)。 | ||
| * | ||
| * 如果用户配置了 tools.postcss,则由用户完全接管 PostCSS 插件列表。 | ||
| */ | ||
| function buildPostcss() { | ||
| function buildDefaultPostcss() { | ||
| return (_, { addPlugins }) => { | ||
@@ -78,2 +80,4 @@ try { | ||
| * @param {object} [pluginOptions.staticResources] - 覆盖引擎静态资源 URL | ||
| * @param {object} [pluginOptions.tools] - 低代码插件支持的 Rsbuild tools 配置 | ||
| * @param {Function} [pluginOptions.tools.postcss] - 自定义 PostCSS 配置 | ||
| * @param {string} [pluginOptions.lowcodeDir] - 低代码源码目录名,默认 'lowcode' | ||
@@ -211,2 +215,5 @@ * @param {string} [pluginOptions.buildTarget] - 构建输出根目录名,默认 'build' | ||
| const userPostcss = config.tools?.postcss ?? pluginOptions.tools?.postcss; | ||
| const shouldUseDefaultPostcss = userPostcss === undefined; | ||
| // 5. 合并到顶层 rsbuildConfig | ||
@@ -216,4 +223,7 @@ // - source.define / source.alias:由用户在 rsbuild.config.ts 自行配置,插件不介入 | ||
| // - server.publicDir:dev 模式下将 .tmp/ 对外暴露,使 /assets-*.json 可访问 | ||
| // - tools.postcss:用户配置时完全接管;未配置时保留默认 #body 选择器前缀 | ||
| const addition = { | ||
| tools: { postcss: buildPostcss() }, | ||
| tools: { | ||
| postcss: shouldUseDefaultPostcss ? buildDefaultPostcss() : userPostcss, | ||
| }, | ||
| dev: { | ||
@@ -220,0 +230,0 @@ progressBar: true, |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
126883
1.21%2934
0.31%136
33.33%