mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor: use vite for demo app
This commit is contained in:
parent
32e33487bd
commit
536f242fcc
7 changed files with 244 additions and 169 deletions
|
@ -37,13 +37,15 @@ export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext
|
|||
changeOrigin: true,
|
||||
logs: true,
|
||||
rewrite: (requestPath) => {
|
||||
const fullPath = '/' + path.join(prefix, requestPath);
|
||||
// Static files
|
||||
if (requestPath.includes('.')) {
|
||||
return '/' + path.join(prefix, requestPath);
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
// In-app routes
|
||||
return requestPath;
|
||||
// We'll gradually migrate our single-page apps to use vite, which can directly return the full path
|
||||
return packagePath === 'demo-app' ? fullPath : requestPath;
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"extends": "@parcel/config-default",
|
||||
"optimizers": {
|
||||
// Disable optimizers in arm64 arch https://github.com/parcel-bundler/parcel/issues/7402
|
||||
"*.{jpg,jpeg,png}": []
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="index.tsx"></script>
|
||||
<script type="module" src="src/index.tsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -5,15 +5,16 @@
|
|||
"author": "Silverhand Inc. <contact@silverhand.io>",
|
||||
"license": "MPL-2.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"start": "parcel src/index.html",
|
||||
"dev": "cross-env PORT=5003 parcel src/index.html --public-url /demo-app --no-cache --hmr-port 6003",
|
||||
"start": "vite",
|
||||
"dev": "vite",
|
||||
"check": "tsc --noEmit",
|
||||
"build": "pnpm check && rm -rf dist && parcel build src/index.html --no-autoinstall --no-cache --public-url /demo-app",
|
||||
"build": "pnpm check && vite build",
|
||||
"lint": "eslint --ext .ts --ext .tsx src",
|
||||
"lint:report": "pnpm lint --format json --output-file report.json",
|
||||
"stylelint": "stylelint \"src/**/*.scss\""
|
||||
|
@ -24,8 +25,6 @@
|
|||
"@logto/phrases": "workspace:^1.12.0",
|
||||
"@logto/react": "^3.0.12",
|
||||
"@logto/schemas": "workspace:^1.18.0",
|
||||
"@parcel/core": "2.9.3",
|
||||
"@parcel/transformer-sass": "2.9.3",
|
||||
"@silverhand/eslint-config": "6.0.1",
|
||||
"@silverhand/eslint-config-react": "6.0.2",
|
||||
"@silverhand/ts-config": "6.0.0",
|
||||
|
@ -39,7 +38,6 @@
|
|||
"i18next-browser-languagedetector": "^8.0.0",
|
||||
"jose": "^5.6.3",
|
||||
"lint-staged": "^15.0.0",
|
||||
"parcel": "2.9.3",
|
||||
"postcss": "^8.4.31",
|
||||
"prettier": "^3.0.0",
|
||||
"react": "^18.3.1",
|
||||
|
@ -47,22 +45,12 @@
|
|||
"react-i18next": "^12.3.1",
|
||||
"stylelint": "^15.0.0",
|
||||
"typescript": "^5.5.3",
|
||||
"vite": "^5.3.4",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.9.0"
|
||||
},
|
||||
"//": "https://github.com/parcel-bundler/parcel/issues/7636",
|
||||
"targets": {
|
||||
"default": {
|
||||
"engines": {
|
||||
"browsers": "defaults"
|
||||
}
|
||||
}
|
||||
},
|
||||
"alias": {
|
||||
"@/*": "./src/$1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "@silverhand/react"
|
||||
},
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
"extends": "./tsconfig.base",
|
||||
"include": [
|
||||
"src",
|
||||
"*.config.ts"
|
||||
]
|
||||
}
|
||||
|
|
47
packages/demo-app/vite.config.ts
Normal file
47
packages/demo-app/vite.config.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
base: '/demo-app',
|
||||
server: {
|
||||
port: 5003,
|
||||
hmr: {
|
||||
port: 6003,
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
{
|
||||
find: /^@\//,
|
||||
replacement: '/src/',
|
||||
},
|
||||
],
|
||||
},
|
||||
optimizeDeps: {
|
||||
include: ['@logto/phrases', '@logto/phrases-experience', '@logto/schemas'],
|
||||
},
|
||||
build: {
|
||||
sourcemap: process.env.NODE_ENV === 'production',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (/\/react[^/]*\//.test(id)) {
|
||||
return 'react';
|
||||
}
|
||||
|
||||
if (id.includes('/@logto/')) {
|
||||
return 'logto';
|
||||
}
|
||||
|
||||
if (id.includes('/node_modules/')) {
|
||||
return 'vendors';
|
||||
}
|
||||
|
||||
const match = /\/lib\/locales\/([^/]+)/.exec(id);
|
||||
if (match?.[1]) {
|
||||
return `phrases-${match[1]}`;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
328
pnpm-lock.yaml
328
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue