Skip to content

Import a 3D Model and automatically assign and export animations

TypeScript
1.3 KB
Raw Blame
import { resolve } from 'path'
import { defineConfig } from 'vite'
import glsl from 'vite-plugin-glsl' // allows us to use external shaders files to be imported into our materials

const is_code_sandbox = 'SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env

export default defineConfig({
  root: 'src/',
  publicDir: '../static/',
  base: './',
  define: {
    // Allowlist only: this is inlined into the public bundle, and the CI env holds secrets (CLOUDFLARE_API_TOKEN).
    PROCESS_ENV: JSON.stringify({
      WORKERS_CI_COMMIT_SHA: process.env.WORKERS_CI_COMMIT_SHA,
      WORKERS_CI_BRANCH: process.env.WORKERS_CI_BRANCH
    })
  },
  server:
    {
      host: true,
      open: !is_code_sandbox // Open window if it's not a CodeSandbox
    },
  build:
    {
      outDir: '../dist',
      // bundled JS/CSS go here instead of the default 'assets', which is the asset library folder in static/
      assetsDir: 'bundle',
      emptyOutDir: true,
      sourcemap: true,
      rollupOptions: {
        input: {
          main: resolve(__dirname, 'src/index.html'),
          create: resolve(__dirname, 'src/create.html'),
          retarget: resolve(__dirname, 'src/retarget/index.html'),
          composer: resolve(__dirname, 'src/composer/index.html')
        }
      }
    },
  plugins:
    [
      glsl()
    ]
})