Skip to content

Commit

Permalink
chore(playground): update vite build to get project name from dsn
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed May 29, 2024
1 parent c2b3230 commit 0cd3b42
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
51 changes: 29 additions & 22 deletions packages/playground/admin/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ import { defineConfig } from 'vite'
import { resolveConfig } from '../../../build/createViteConfig.js'
import { resolve } from 'node:path'

export default defineConfig({
base: '/',
plugins: [
react(),
{
name: 'rewrite-middleware',
configureServer(serve) {
serve.middlewares.use((req, res, next) => {
if (req.url === '/app' || req.url?.startsWith('/app/') && !req.url?.match(/\.\w+($|\?)/)) {
req.url = '/app/'
}
next()
})
export default defineConfig(() => {
const dsn = process.argv.find(it => it.includes('://'))
const projectName = dsn ? new URL(dsn).username : null
return ({
define: projectName ? {
'import.meta.env.VITE_CONTEMBER_ADMIN_PROJECT_NAME': JSON.stringify(projectName),
} : {},
base: '/',
plugins: [
react(),
{
name: 'rewrite-middleware',
configureServer(serve) {
serve.middlewares.use((req, res, next) => {
if (req.url === '/app' || req.url?.startsWith('/app/') && !req.url?.match(/\.\w+($|\?)/)) {
req.url = '/app/'
}
next()
})
},
},
},
],
resolve: resolveConfig,
build: {
rollupOptions: {
input: {
root: resolve(__dirname, './index.html'),
app: resolve(__dirname, './app/index.html'),
],
resolve: resolveConfig,
build: {
rollupOptions: {
input: {
root: resolve(__dirname, './index.html'),
app: resolve(__dirname, './app/index.html'),
},
},
},
},

})
})
2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "vite build admin",
"contember": "docker-compose run contember-cli",
"deploy": "yarn -- contember deploy playground --admin http://admin-server:4000 --yes",
"deploy": "yarn run build \"$0\" && docker-compose run --no-deps contember-cli deploy \"$@\" --root ",
"start": "vite dev admin --port ${VITE_PORT:-3000} --host 0.0.0.0",
"test": "vitest --root ./ --environment jsdom"
},
Expand Down

0 comments on commit 0cd3b42

Please sign in to comment.