theatre/packages/playground/devEnv/servePlayground.ts
2021-06-18 13:05:06 +02:00

39 lines
882 B
TypeScript

import path from 'path'
import {
convertObjectToWebpackDefinePaths,
getEnvConfig,
} from '../../../theatre/devEnv/webpack/createWebpackConfig'
const playgroundDir = path.join(__dirname, '..')
const envConfig = getEnvConfig(true)
const port = 8080
require('esbuild')
.serve(
{
port,
servedir: path.join(playgroundDir, 'src'),
},
{
entryPoints: [path.join(playgroundDir, 'src/index.tsx')],
target: ['firefox88'],
loader: {'.png': 'file'},
// outdir: '.',
// watch: true,
bundle: true,
sourcemap: true,
define: {
global: 'window',
'$env.isCore': false,
...convertObjectToWebpackDefinePaths({
process: {env: envConfig},
$env: envConfig,
}),
},
},
)
.then((server: unknown) => {
console.log('serving', 'http://localhost:' + port)
})