这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(env): setup env prefix and typescript for client-side #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/tuono-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
.tuono
out
target

# Ignore local env files
*.local
1 change: 1 addition & 0 deletions examples/tuono-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"types": ["tuono/build-client"],

/* Bundler mode */
"moduleResolution": "bundler",
Expand Down
3 changes: 3 additions & 0 deletions examples/tuono-tutorial/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
.tuono
out
target

# Ignore local env files
*.local
4 changes: 0 additions & 4 deletions examples/tuono-tutorial/src/css-modules.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions examples/tuono-tutorial/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"jsx": "react-jsx",
"useDefineForClassFields": true,
"types": ["tuono/build-client"],

// Modules
"module": "ESNext",
Expand Down
3 changes: 3 additions & 0 deletions examples/with-mdx/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
.tuono
out
target

# Ignore local env files
*.local
1 change: 1 addition & 0 deletions examples/with-mdx/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"types": ["tuono/build-client"],

/* Bundler mode */
"moduleResolution": "bundler",
Expand Down
3 changes: 3 additions & 0 deletions examples/with-tailwind/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ node_modules
.tuono
out
target

# Ignore local env files
*.local
1 change: 1 addition & 0 deletions examples/with-tailwind/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"types": ["tuono/build-client"],

/* Bundler mode */
"moduleResolution": "bundler",
Expand Down
3 changes: 3 additions & 0 deletions packages/tuono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"types": "./dist/esm/build/index.d.ts",
"default": "./dist/esm/build/index.js"
},
"./build-client": {
"types": "./dist/esm/build-client/index.d.ts"
},
"./config": {
"types": "./dist/esm/config/index.d.ts",
"default": "./dist/esm/config/index.js"
Expand Down
1 change: 1 addition & 0 deletions packages/tuono/src/build-client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'vite/client'
1 change: 1 addition & 0 deletions packages/tuono/src/build/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const DOT_TUONO_FOLDER_NAME = '.tuono'
export const CONFIG_FOLDER_NAME = 'config'
export const CONFIG_FILE_NAME = 'config.mjs'
export const SERVER_CONFIG_NAME = 'config.json'
export const ENV_PREFIX = 'TUONO_PUBLIC_'
2 changes: 2 additions & 0 deletions packages/tuono/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { TuonoConfig } from '../config'

import { blockingAsync } from './utils'
import { createJsonConfig, loadConfig } from './config'
import { ENV_PREFIX } from './constants'

const VITE_SSR_PLUGINS: Array<Plugin> = [
{
Expand Down Expand Up @@ -45,6 +46,7 @@ function createBaseViteConfigFromTuonoConfig(
publicDir: '../public',
cacheDir: 'cache',
envDir: '../',
envPrefix: ENV_PREFIX,

resolve: {
alias: tuonoConfig.vite?.alias ?? {},
Expand Down
1 change: 1 addition & 0 deletions packages/tuono/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default mergeConfig(
'./src/index.ts',
'./src/build/index.ts',
'./src/config/index.ts',
'./src/build-client/index.ts',
'./src/ssr/index.ts',
'./src/hydration/index.tsx',
],
Expand Down
Loading