Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerioageno committed Nov 25, 2024
1 parent adcfe5a commit e4045e7
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 135 deletions.
254 changes: 127 additions & 127 deletions packages/tuono/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,147 +8,147 @@ import { loadConfig, blockingAsync } from './utils'
const VITE_PORT = 3001

const BASE_CONFIG: InlineConfig = {
root: '.tuono',
logLevel: 'silent',
publicDir: '../public',
cacheDir: 'cache',
envDir: '../',
optimizeDeps: {
exclude: ['@mdx-js/react'],
},
plugins: [
{ enforce: 'pre', ...mdx({ providerImportSource: '@mdx-js/react' }) },
// @ts-ignore: TS configuration issue.
react({ include: /\.(jsx|js|mdx|md|tsx|ts)$/ }),
ViteFsRouter(),
LazyLoadingPlugin(),
],
root: '.tuono',
logLevel: 'silent',
publicDir: '../public',
cacheDir: 'cache',
envDir: '../',
optimizeDeps: {
exclude: ['@mdx-js/react'],
},
plugins: [
{ enforce: 'pre', ...mdx({ providerImportSource: '@mdx-js/react' }) },
// @ts-ignore: TS configuration issue.
react({ include: /\.(jsx|js|mdx|md|tsx|ts)$/ }),
ViteFsRouter(),
LazyLoadingPlugin(),
],
}

const developmentSSRBundle = () => {
blockingAsync(async () => {
const config = await loadConfig()
await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
ssr: true,
minify: false,
outDir: 'server',
emptyOutDir: true,
rollupOptions: {
input: './.tuono/server-main.tsx',
// Silent all logs
onLog() { },
output: {
entryFileNames: 'dev-server.js',
format: 'iife',
},
},
},
ssr: {
target: 'webworker',
noExternal: true,
},
})
})
blockingAsync(async () => {
const config = await loadConfig()
await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
ssr: true,
minify: false,
outDir: 'server',
emptyOutDir: true,
rollupOptions: {
input: './.tuono/server-main.tsx',
// Silent all logs
onLog() {},
output: {
entryFileNames: 'dev-server.js',
format: 'iife',
},
},
},
ssr: {
target: 'webworker',
noExternal: true,
},
})
})
}

const developmentCSRWatch = () => {
blockingAsync(async () => {
const config = await loadConfig()
const server = await createServer({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
// Entry point for the development vite proxy
base: '/vite-server/',
blockingAsync(async () => {
const config = await loadConfig()
const server = await createServer({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
// Entry point for the development vite proxy
base: '/vite-server/',

server: {
port: VITE_PORT,
strictPort: true,
},
build: {
manifest: true,
emptyOutDir: true,
rollupOptions: {
input: './.tuono/client-main.tsx',
},
},
})
await server.listen()
})
server: {
port: VITE_PORT,
strictPort: true,
},
build: {
manifest: true,
emptyOutDir: true,
rollupOptions: {
input: './.tuono/client-main.tsx',
},
},
})
await server.listen()
})
}

const buildProd = () => {
blockingAsync(async () => {
const config = await loadConfig()
await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
manifest: true,
emptyOutDir: true,
outDir: '../out/client',
rollupOptions: {
input: './.tuono/client-main.tsx',
},
},
})
blockingAsync(async () => {
const config = await loadConfig()
await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
manifest: true,
emptyOutDir: true,
outDir: '../out/client',
rollupOptions: {
input: './.tuono/client-main.tsx',
},
},
})

await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
ssr: true,
minify: true,
outDir: '../out/server',
emptyOutDir: true,
rollupOptions: {
input: './.tuono/server-main.tsx',
output: {
entryFileNames: 'prod-server.js',
format: 'iife',
},
},
},
ssr: {
target: 'webworker',
noExternal: true,
},
})
})
await build({
resolve: {
alias: config.vite?.alias || {},
},
...BASE_CONFIG,
build: {
ssr: true,
minify: true,
outDir: '../out/server',
emptyOutDir: true,
rollupOptions: {
input: './.tuono/server-main.tsx',
output: {
entryFileNames: 'prod-server.js',
format: 'iife',
},
},
},
ssr: {
target: 'webworker',
noExternal: true,
},
})
})
}

const buildConfig = () => {
blockingAsync(async () => {
await build({
root: '.tuono',
logLevel: 'silent',
cacheDir: 'cache',
envDir: '../',
build: {
ssr: true,
outDir: 'config',
emptyOutDir: true,
rollupOptions: {
input: './tuono.config.ts',
output: {
entryFileNames: 'config.js',
name: 'config',
format: 'cjs',
},
},
},
})
})
blockingAsync(async () => {
await build({
root: '.tuono',
logLevel: 'silent',
cacheDir: 'cache',
envDir: '../',
build: {
ssr: true,
outDir: 'config',
emptyOutDir: true,
rollupOptions: {
input: './tuono.config.ts',
output: {
entryFileNames: 'config.js',
name: 'config',
format: 'cjs',
},
},
},
})
})
}

export { buildProd, buildConfig, developmentCSRWatch, developmentSSRBundle }
16 changes: 8 additions & 8 deletions packages/tuono/src/build/utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { TuonoConfig } from '../config'

export const loadConfig = async (): Promise<TuonoConfig> => {
try {
return await import(`${process.cwd()}/.tuono/config/config.js`)
} catch {
return {}
}
try {
return await import(`${process.cwd()}/.tuono/config/config.js`)
} catch {
return {}
}
}

export const blockingAsync = (callback: () => Promise<void>) => {
; (async () => {
await callback()
})()
;(async () => {
await callback()
})()
}

0 comments on commit e4045e7

Please sign in to comment.