From e4045e713509bb88bbc99b02fc1c0f192dab76b6 Mon Sep 17 00:00:00 2001 From: Valerio Ageno Date: Mon, 25 Nov 2024 21:14:08 +0100 Subject: [PATCH] fix: formatting --- packages/tuono/src/build/index.ts | 254 +++++++++++++++--------------- packages/tuono/src/build/utils.ts | 16 +- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/packages/tuono/src/build/index.ts b/packages/tuono/src/build/index.ts index 596ab6c3..c42c4502 100644 --- a/packages/tuono/src/build/index.ts +++ b/packages/tuono/src/build/index.ts @@ -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 } diff --git a/packages/tuono/src/build/utils.ts b/packages/tuono/src/build/utils.ts index 51a0192f..f22f6974 100644 --- a/packages/tuono/src/build/utils.ts +++ b/packages/tuono/src/build/utils.ts @@ -1,15 +1,15 @@ import { TuonoConfig } from '../config' export const loadConfig = async (): Promise => { - 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) => { - ; (async () => { - await callback() - })() + ;(async () => { + await callback() + })() }