From 945cc18b0485c39bd9472ec51096acf8aaa18c63 Mon Sep 17 00:00:00 2001 From: Nicolas Merget <104347736+nmerget@users.noreply.github.com> Date: Thu, 11 Apr 2024 08:41:23 +0200 Subject: [PATCH] chore: prepare patternhub to use static assets provided by react showcase (#2342) --- .../patternhub/components/default-page.tsx | 4 ++- .../patternhub/components/src/tsconfig.json | 27 ------------------- showcases/patternhub/package.json | 2 +- .../public/{ => assets}/images/db_logo.svg | 0 showcases/patternhub/public/site.webmanifest | 2 +- showcases/patternhub/scripts/fix-base-path.js | 8 ++++++ 6 files changed, 13 insertions(+), 30 deletions(-) delete mode 100644 showcases/patternhub/components/src/tsconfig.json rename showcases/patternhub/public/{ => assets}/images/db_logo.svg (100%) create mode 100644 showcases/patternhub/scripts/fix-base-path.js diff --git a/showcases/patternhub/components/default-page.tsx b/showcases/patternhub/components/default-page.tsx index 341d474359b..72f1f886dcf 100644 --- a/showcases/patternhub/components/default-page.tsx +++ b/showcases/patternhub/components/default-page.tsx @@ -84,7 +84,9 @@ const DefaultPage = ({ children }: any) => { onToggle={setDrawerOpen} slotBrand={ {process.env.NEXT_PUBLIC_APP_NAME} diff --git a/showcases/patternhub/components/src/tsconfig.json b/showcases/patternhub/components/src/tsconfig.json deleted file mode 100644 index ad8e8da3da5..00000000000 --- a/showcases/patternhub/components/src/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "strict": false, - "allowUnreachableCode": false, - "allowSyntheticDefaultImports": true, - "declaration": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "lib": ["dom", "es2015"], - "module": "es2015", - "moduleResolution": "node", - "noImplicitAny": false, - "noImplicitReturns": false, - "noUnusedLocals": false, - "noUnusedParameters": false, - "outDir": "dist", - "removeComments": false, - "sourceMap": true, - "jsx": "react", - "target": "ES6" - }, - "include": ["**/*.ts", "**/*.tsx"], - "exclude": ["node_modules", "**/*.spec.tsx", "dist"], - "compileOnSave": false, - "buildOnSave": false -} diff --git a/showcases/patternhub/package.json b/showcases/patternhub/package.json index 24407c31c70..dd0d55cc13b 100644 --- a/showcases/patternhub/package.json +++ b/showcases/patternhub/package.json @@ -13,10 +13,10 @@ "compile:03_copy-docs": "cpr ../../docs ./public/docs -o", "compile:04_components": "node scripts/esbuild-generate.mjs", "compile:05_run": "node generated.js", + "compile:06_replace_base": "node scripts/fix-base-path.js", "dev": "cross-env NEXT_PUBLIC_BASE_PATH=/mono/sub npm-run-all compile -p open next:dev", "lint": "next lint", "next:dev": "next dev", - "next:start": "next start", "open": "open-cli http://localhost:3000/mono/sub", "prebuild:app": "cpr ../../node_modules/iframe-resizer/js/ public/iframe-resizer -o", "start": "cross-env NEXT_PUBLIC_BASE_PATH=/mono/sub npm-run-all compile next:dev" diff --git a/showcases/patternhub/public/images/db_logo.svg b/showcases/patternhub/public/assets/images/db_logo.svg similarity index 100% rename from showcases/patternhub/public/images/db_logo.svg rename to showcases/patternhub/public/assets/images/db_logo.svg diff --git a/showcases/patternhub/public/site.webmanifest b/showcases/patternhub/public/site.webmanifest index c5b4ef35c07..34a49346fc0 100644 --- a/showcases/patternhub/public/site.webmanifest +++ b/showcases/patternhub/public/site.webmanifest @@ -3,7 +3,7 @@ "name": "", "icons": [ { - "src": "/images/db_logo.svg", + "src": "/assets/images/db_logo.svg", "type": "image/svg", "sizes": "192x192" } diff --git a/showcases/patternhub/scripts/fix-base-path.js b/showcases/patternhub/scripts/fix-base-path.js new file mode 100644 index 00000000000..93f6900ac46 --- /dev/null +++ b/showcases/patternhub/scripts/fix-base-path.js @@ -0,0 +1,8 @@ +import Replace from 'replace-in-file'; + +const option = { + files: './pages/components/**/*.tsx', + from: 'import.meta.env.BASE_URL', + to: 'process.env.NEXT_PUBLIC_BASE_PATH' +}; +Replace.replaceInFileSync(option);