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

This commit is contained in:
Jacob Marshall
2025-02-23 13:17:23 +00:00
committed by GitHub
parent de5ac53cc3
commit d679982949
14 changed files with 24 additions and 4 deletions
+3
View File
@@ -11,3 +11,6 @@ node_modules
.tuono .tuono
out out
target target
# Ignore local env files
*.local
+1
View File
@@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"types": ["tuono/build-client"],
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
+3
View File
@@ -11,3 +11,6 @@ node_modules
.tuono .tuono
out out
target target
# Ignore local env files
*.local
-4
View File
@@ -1,4 +0,0 @@
declare module '*.module.css' {
const classes: Record<string, string>
export default classes
}
+1
View File
@@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"jsx": "react-jsx", "jsx": "react-jsx",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"types": ["tuono/build-client"],
// Modules // Modules
"module": "ESNext", "module": "ESNext",
+3
View File
@@ -11,3 +11,6 @@ node_modules
.tuono .tuono
out out
target target
# Ignore local env files
*.local
+1
View File
@@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"types": ["tuono/build-client"],
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
+3
View File
@@ -11,3 +11,6 @@ node_modules
.tuono .tuono
out out
target target
# Ignore local env files
*.local
+1
View File
@@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
"types": ["tuono/build-client"],
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
+3
View File
@@ -27,6 +27,9 @@
"types": "./dist/esm/build/index.d.ts", "types": "./dist/esm/build/index.d.ts",
"default": "./dist/esm/build/index.js" "default": "./dist/esm/build/index.js"
}, },
"./build-client": {
"types": "./dist/esm/build-client/index.d.ts"
},
"./config": { "./config": {
"types": "./dist/esm/config/index.d.ts", "types": "./dist/esm/config/index.d.ts",
"default": "./dist/esm/config/index.js" "default": "./dist/esm/config/index.js"
+1
View File
@@ -0,0 +1 @@
import 'vite/client'
+1
View File
@@ -2,3 +2,4 @@ export const DOT_TUONO_FOLDER_NAME = '.tuono'
export const CONFIG_FOLDER_NAME = 'config' export const CONFIG_FOLDER_NAME = 'config'
export const CONFIG_FILE_NAME = 'config.mjs' export const CONFIG_FILE_NAME = 'config.mjs'
export const SERVER_CONFIG_NAME = 'config.json' export const SERVER_CONFIG_NAME = 'config.json'
export const ENV_PREFIX = 'TUONO_PUBLIC_'
+2
View File
@@ -8,6 +8,7 @@ import type { TuonoConfig } from '../config'
import { blockingAsync } from './utils' import { blockingAsync } from './utils'
import { createJsonConfig, loadConfig } from './config' import { createJsonConfig, loadConfig } from './config'
import { ENV_PREFIX } from './constants'
const VITE_SSR_PLUGINS: Array<Plugin> = [ const VITE_SSR_PLUGINS: Array<Plugin> = [
{ {
@@ -45,6 +46,7 @@ function createBaseViteConfigFromTuonoConfig(
publicDir: '../public', publicDir: '../public',
cacheDir: 'cache', cacheDir: 'cache',
envDir: '../', envDir: '../',
envPrefix: ENV_PREFIX,
resolve: { resolve: {
alias: tuonoConfig.vite?.alias ?? {}, alias: tuonoConfig.vite?.alias ?? {},
+1
View File
@@ -13,6 +13,7 @@ export default mergeConfig(
'./src/index.ts', './src/index.ts',
'./src/build/index.ts', './src/build/index.ts',
'./src/config/index.ts', './src/config/index.ts',
'./src/build-client/index.ts',
'./src/ssr/index.ts', './src/ssr/index.ts',
'./src/hydration/index.tsx', './src/hydration/index.tsx',
], ],