From 2fa1363b4e241c0bbda95d1e8f16cd19d0f13865 Mon Sep 17 00:00:00 2001 From: luhc228 Date: Mon, 26 Feb 2024 10:11:06 +0800 Subject: [PATCH] feat: match page paths (#6801) * feat: match page paths * chore: update version --- packages/icejs/package.json | 6 +++--- packages/plugin-store/CHANGELOG.md | 4 ++++ packages/plugin-store/package.json | 4 ++-- .../plugin-store/src/babelPluginReplacePath.ts | 14 +++++++------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/icejs/package.json b/packages/icejs/package.json index 15fca7df5c..7d73da8dbd 100644 --- a/packages/icejs/package.json +++ b/packages/icejs/package.json @@ -1,6 +1,6 @@ { "name": "ice.js", - "version": "2.6.7", + "version": "2.6.8", "description": "command line interface and builtin plugin for icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "", @@ -33,7 +33,7 @@ "build-plugin-ice-request": "2.0.1", "build-plugin-ice-router": "2.1.3", "build-plugin-ice-ssr": "3.1.4", - "build-plugin-ice-store": "2.0.9", + "build-plugin-ice-store": "2.0.10", "build-plugin-react-app": "2.2.4", "build-plugin-pwa": "1.1.1", "build-plugin-speed": "1.0.1", @@ -50,4 +50,4 @@ "npm": ">=3.0.0" }, "gitHead": "cf40d079714b437417e77b444b078cf83286f2fc" -} \ No newline at end of file +} diff --git a/packages/plugin-store/CHANGELOG.md b/packages/plugin-store/CHANGELOG.md index 934382a9a1..865e0d3175 100644 --- a/packages/plugin-store/CHANGELOG.md +++ b/packages/plugin-store/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.10 + +- [feat] match page names with `-` + ## 2.0.9 - [fix] convert kebab-case to PascalCase for `Layout` name, such as `hello-wordLayout` to `HelloWorldLayout` diff --git a/packages/plugin-store/package.json b/packages/plugin-store/package.json index b6a222b94d..b9c125a470 100644 --- a/packages/plugin-store/package.json +++ b/packages/plugin-store/package.json @@ -1,6 +1,6 @@ { "name": "build-plugin-ice-store", - "version": "2.0.9", + "version": "2.0.10", "description": "builtin `@ice/store` in icejs", "author": "ice-admin@alibaba-inc.com", "homepage": "https://github.com/alibaba/ice#readme", @@ -38,4 +38,4 @@ "devDependencies": { "vite": "^2.4.3" } -} \ No newline at end of file +} diff --git a/packages/plugin-store/src/babelPluginReplacePath.ts b/packages/plugin-store/src/babelPluginReplacePath.ts index 6f0b995140..c38f0ad98d 100644 --- a/packages/plugin-store/src/babelPluginReplacePath.ts +++ b/packages/plugin-store/src/babelPluginReplacePath.ts @@ -2,9 +2,9 @@ import * as path from 'path'; // match: // eg: src/pages/home | src/pages/home/index | src/pages/home/index(.tsx|.jsx) | src/pages/index(.tsx|jsx) -const pagePathRegExp = /src\/pages\/\w+((.tsx|.jsx?)$|(\/index(.tsx|.jsx?)?)?$)/; +const pagePathRegExp = /src\/pages\/(?:[^/*"]+)*((.tsx|.jsx?)$|(\/index(.tsx|.jsx?)?)?$)/; // egļ¼šsrc/pages/home/Layout -const layoutPathRegExp = /src\/pages\/\w+\/Layout/; +const layoutPathRegExp = /src\/pages\/(?:[^/*"]+)*\/Layout/; module.exports = ({ types: t }, { routesPaths, alias, tempDir, applyMethod, rootDir }) => { return { @@ -87,14 +87,14 @@ interface IGetConfigRoutePathParams { // case2: { "@src": "./src", "@pages": "./src/pages" } // case3: { "@": "./src", "@/pages": "./src/pages" } function matchAliasPath( - { - alias, + { + alias, value, applyMethod, rootDir, - }: { + }: { alias: IAlias; - value: string; + value: string; applyMethod: Function; rootDir: string; }): string { @@ -121,7 +121,7 @@ function matchRelativePath( value, applyMethod, rootDir, - }: { + }: { routesPath: string; value: string; applyMethod: Function;