Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

build.js

30 lines771 Bytes

1#!/usr/bin/env node
2import * as esbuild from 'esbuild'
3import { solidPlugin } from 'esbuild-plugin-solid'
4import { tanstackRouter } from '@tanstack/router-plugin/esbuild'
5​
6const isDev = process.argv.includes('--dev')
7​
8const ctx = await esbuild.context({
9 entryPoints: ['src/main.tsx'],
10 outfile: 'dist/main.js',
11 minify: !isDev,
12 bundle: true,
13 format: 'esm',
14 target: ['esnext'],
15 sourcemap: true,
16 conditions: ['style'],
17 plugins: [
18 solidPlugin(),
19 tanstackRouter({ target: 'solid', autoCodeSplitting: true }),
20 ],
21})
22​
23if (isDev) {
24 await ctx.watch()
25 const { host, port } = await ctx.serve({ servedir: '.', port: 3005 })
26 console.log(`Server running at http://${host || 'localhost'}:${port}`)
27} else {
28 await ctx.rebuild()
29 await ctx.dispose()