Skip to content

Commit

Permalink
fix: 解决sveltekit 子目录未配置问题
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanEichDisciple committed Aug 21, 2024
1 parent 765c81b commit f1dca76
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_BASE=/
VITE_BASE=''
VITE_BASE_URL=http://localhost:3000/api/v1
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_BASE=/hospital/
VITE_BASE=/hospital
VITE_BASE_URL=http://localhost:3000/api/v1
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@types/eslint": "8.56.10",
"autoprefixer": "^10.4.20",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.43.0",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import adapter from '@sveltejs/adapter-node';

import dotenv from 'dotenv';

// 加载环境变量
dotenv.config();

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
adapter: adapter(),
paths: {
base: process.env.VITE_BASE || '/hospital',
}
}
};

Expand Down
3 changes: 1 addition & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { defineConfig, loadEnv } from 'vite';

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const { VITE_BASE, VITE_JSCODE } = env;
const { VITE_JSCODE } = env;

return {
base: VITE_BASE || '/',
plugins: [sveltekit()],
server: {
proxy: {
Expand Down

0 comments on commit f1dca76

Please sign in to comment.