Skip to content

Commit

Permalink
feat(env): setup env prefix and typescript for client-side (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobhq authored Feb 23, 2025
1 parent de5ac53 commit d679982
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 4 deletions.
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

0 comments on commit d679982

Please sign in to comment.