@lark-apaas/fullstack-rspack-preset 1.0.14-alpha.tea.1 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -5,6 +5,7 @@ exports.defineConfig = createFullstackRspackConfig;
5
5
  const webpack_merge_1 = require("webpack-merge");
6
6
  const devtool_kits_1 = require("@lark-apaas/devtool-kits");
7
7
  const preset_1 = require("./preset");
8
+ const normalize_base_path_1 = require("./utils/normalize-base-path");
8
9
  /**
9
10
  * 定义 Fullstack Rspack 配置
10
11
  *
@@ -56,9 +57,9 @@ function createFullstackRspackConfig(overrides = {}) {
56
57
  const needRoutes = process.env.NEED_ROUTES !== 'false'; // 默认 true
57
58
  // 3. 处理路径配置
58
59
  const clientBasePath = (0, devtool_kits_1.normalizeBasePath)(process.env.CLIENT_BASE_PATH || '/');
59
- const publicPath = isDev
60
+ const publicPath = (0, normalize_base_path_1.normalizeBasePathWithoutTrailingSlash)(isDev
60
61
  ? process.env.CLIENT_BASE_PATH || '/'
61
- : process.env.ASSETS_CDN_PATH || '/';
62
+ : process.env.ASSETS_CDN_PATH || '/');
62
63
  // 4. 调用原有的 preset 函数生成基础配置
63
64
  // 注意:enableInspector 目前在 preset 中由 isDev 控制,暂不暴露为独立参数
64
65
  const baseConfig = (0, preset_1.createRecommendRspackConfig)({
package/lib/preset.js CHANGED
@@ -16,6 +16,7 @@ const dev_server_snapdom_proxy_1 = require("./utils/dev-server-snapdom-proxy");
16
16
  function createRecommendRspackConfig(options) {
17
17
  const { isDev = true, enableReactRefresh = isDev, needRoutes = true, clientBasePath = '', publicPath = '', // 静态资源路径
18
18
  } = options;
19
+ const assetsCDNPath = publicPath + '/';
19
20
  const rootDir = process.cwd();
20
21
  const serverPort = process.env.SERVER_PORT || '3000';
21
22
  return {
@@ -313,7 +314,7 @@ function createRecommendRspackConfig(options) {
313
314
  },
314
315
  },
315
316
  output: {
316
- publicPath,
317
+ publicPath: assetsCDNPath,
317
318
  path: path_1.default.resolve(rootDir, 'dist/client'),
318
319
  clean: false,
319
320
  globalObject: 'this',
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
3
+ * @param basePath 原始基础路径
4
+ * @returns 标准化后的基础路径
5
+ */
6
+ export declare function normalizeBasePathWithoutTrailingSlash(basePath: string): string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeBasePathWithoutTrailingSlash = normalizeBasePathWithoutTrailingSlash;
4
+ /**
5
+ * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
6
+ * @param basePath 原始基础路径
7
+ * @returns 标准化后的基础路径
8
+ */
9
+ function normalizeBasePathWithoutTrailingSlash(basePath) {
10
+ const basePathWithoutTrailingSlash = basePath.endsWith('/')
11
+ ? basePath.slice(0, -1)
12
+ : basePath;
13
+ return basePathWithoutTrailingSlash;
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.14-alpha.tea.1",
3
+ "version": "1.0.15",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",