theatre/packages/playground/devEnv/servePlayground.ts

39 lines
852 B
TypeScript
Raw Normal View History

2021-06-18 13:05:06 +02:00
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',
...convertObjectToWebpackDefinePaths({
process: {env: envConfig},
$env: envConfig,
}),
},
},
)
.then((server: unknown) => {
console.log('serving', 'http://localhost:' + port)
})