theatre/packages/playground/devEnv/vite.config.ts

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-02-27 21:25:15 +01:00
import {defineConfig} from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import {getAliasesFromTsConfigForRollup} from '../../../devEnv/getAliasesFromTsConfig'
import {definedGlobals} from '../../../theatre/devEnv/buildUtils'
/*
We're using vite instead of the older pure-esbuild setup. The tradeoff is
that page reloads are much slower (>1s diff), while hot reload of react components
are instantaneous and of course, they preserve state.
@todo Author feels that the slow reloads are quite annoying and disruptive to flow,
so if you find a way to make them faster, please do.
*/
const playgroundDir = path.join(__dirname, '..')
const port = 8080
// https://vitejs.dev/config/
export default defineConfig({
root: path.join(playgroundDir, './src'),
2022-03-18 15:58:26 +01:00
build: {
outDir: '../build',
minify: false,
emptyOutDir: true,
},
2022-02-28 13:15:27 +01:00
2022-02-27 21:25:15 +01:00
assetsInclude: ['**/*.gltf', '**/*.glb'],
server: {
port,
},
plugins: [react()],
resolve: {
/*
This will alias paths like `@theatre/core` to `path/to/theatre/core/src/index.ts` and so on,
so vite won't treat the monorepo's packages as externals and won't pre-bundle them.
*/
alias: [...getAliasesFromTsConfigForRollup()],
},
2022-02-28 13:15:27 +01:00
define: {...definedGlobals, 'window.__IS_VISUAL_REGRESSION_TESTING': 'true'},
2022-02-27 21:25:15 +01:00
})