Files
pretix_original/vite.config.ts
T
Mira Weller 95cd0d5e38 Squashed commit of the following:
commit 2177bebf6a
Merge: ea613bf271 d08216d8c5
Author: Mira Weller <weller@rami.io>
Date:   Fri Aug 7 21:22:31 2026 +0200

    Merge branch 'master' into questions-vue3

commit ea613bf271
Author: Mira Weller <weller@rami.io>
Date:   Fri Aug 7 21:21:35 2026 +0200

    wip

commit c8bed5e3b9
Author: Mira Weller <weller@rami.io>
Date:   Fri Aug 7 10:15:00 2026 +0200

    rename get_cart to get_cart_positions (keep old name alive)

commit 1ec27fff05
Author: Mira Weller <weller@rami.io>
Date:   Fri Aug 7 10:01:38 2026 +0200

    filter questionnaires by sales channel

commit 0294f205d0
Author: Mira Weller <weller@rami.io>
Date:   Thu Aug 6 20:06:05 2026 +0200

    refactor: extract build_requested_valid_from_field method

commit 3424aacdc3
Author: Mira Weller <weller@rami.io>
Date:   Thu Aug 6 20:05:44 2026 +0200

    rename presale question forms and mixins

commit 4012889076
Author: Mira Weller <weller@rami.io>
Date:   Thu Aug 6 19:42:29 2026 +0200

    rebase migration

commit fe15d71cd2
Merge: 3ea7ea31b6 4d9dfa88fe
Author: Mira Weller <weller@rami.io>
Date:   Thu Aug 6 19:25:44 2026 +0200

    Merge branch 'master' into questions-vue3

    # Conflicts:
    #	src/pretix/base/forms/questions.py
    #	src/pretix/base/middleware.py
    #	src/pretix/base/templates/pretixbase/redirect.html

commit 3ea7ea31b6
Author: Mira Weller <weller@rami.io>
Date:   Fri Jul 24 17:37:46 2026 +0200

    wip

commit 5b34a25fb5
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 16:21:11 2026 +0200

    use questionnaire data for rendering checkout questions step

commit 9467f1d08d
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 15:54:14 2026 +0200

    refactor: extract build_system_question_field method

commit 85344a7690
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 15:50:41 2026 +0200

    refactor: extract build_user_question_field method

commit 3b47f4aaa7
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 15:49:34 2026 +0200

    refactor: cartpos / orderpos

commit 0309b05121
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:52:18 2026 +0100

    vite config: allow cors access from pretix.work subdomains

commit ad092ae0d1
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:35:33 2026 +0200

    re-add vue-slicksort dep

commit 9f42d679cc
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:28:53 2026 +0200

    rebase migration

commit 9eae9c6de7
Merge: 84c51e031e 694b915d89
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:24:49 2026 +0200

    Merge branch 'master' into questions-vue3

    # Conflicts:
    #	.github/workflows/tests.yml
    #	.gitignore
    #	Dockerfile
    #	package-lock.json
    #	package.json
    #	src/pretix/base/management/commands/runserver.py
    #	src/pretix/base/middleware.py
    #	src/pretix/base/templatetags/vite.py
    #	src/pretix/control/forms/global_settings.py
    #	src/pretix/control/templates/pretixcontrol/checkin/list_edit.html
    #	src/pretix/control/views/item.py
    #	src/pretix/presale/views/widget.py
    #	src/pretix/settings.py
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/App.vue
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/constants.ts
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/django-interop.ts
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/lookup-select2.vue
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/timefield.vue
    #	src/pretix/static/pretixcontrol/js/ui/checkinrules/viz-node.vue
    #	src/pretix/static/pretixpresale/widget/index.html
    #	src/pretix/static/pretixpresale/widget/src/api.ts
    #	src/pretix/static/pretixpresale/widget/src/button.ts
    #	src/pretix/static/pretixpresale/widget/src/components/PriceBox.vue
    #	src/pretix/static/pretixpresale/widget/src/main.ts
    #	src/pretix/static/pretixpresale/widget/src/sharedStore.ts
    #	src/pretix/static/pretixpresale/widget/src/utils.ts
    #	src/pretix/static/pretixpresale/widget/src/widget.ts
    #	src/tests/e2e/conftest.py
    #	vite.config.ts

commit 84c51e031e
Merge: 902ee9242e 222b453b43
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:20:05 2026 +0200

    Merge branch 'master' into questions-vue3

commit 902ee9242e
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:19:26 2026 +0200

    css comment

commit b758efd4a9
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:19:19 2026 +0200

    question dependencies

commit c68fe00502
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:18:00 2026 +0200

    add data field edit link

commit b7da9bb6c1
Author: Mira Weller <weller@rami.io>
Date:   Wed Jun 17 12:16:20 2026 +0200

    handle hidden questions

commit 897120d3da
Author: Mira Weller <weller@rami.io>
Date:   Tue May 12 13:04:08 2026 +0200

    add ts model definitions

commit 09abc5725e
Author: Mira Weller <weller@rami.io>
Date:   Tue May 12 11:30:12 2026 +0200

    reorder and save

commit 9a7d5abb1f
Author: Mira Weller <weller@rami.io>
Date:   Tue May 12 11:29:37 2026 +0200

    fix unhandled exception in taxrules API

commit 3cee5f524b
Author: Mira Weller <weller@rami.io>
Date:   Tue May 5 18:12:21 2026 +0200

    use slicksort for reordering questionnaires and questions

commit 3a1a6b988e
Author: Mira Weller <weller@rami.io>
Date:   Tue Apr 28 19:23:35 2026 +0200

    improve i18n, implement "add text block" dialog

commit bdc720f5a2
Author: Mira Weller <weller@rami.io>
Date:   Fri Mar 27 18:57:22 2026 +0100

    wip

commit 583184af38
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 21:45:32 2026 +0100

    change existing views

commit 63d9f7cea8
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 21:45:32 2026 +0100

    adapt vue app to new data model (wip)

commit c3d6fb1bd6
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 21:44:47 2026 +0100

    add Questionnaire and QuestionnaireChild models and their API; migrate existing data

commit bb43acd257
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:52:28 2026 +0100

    vite config: add questionnaires app

commit e0744951e8
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:52:18 2026 +0100

    vite config: allow cors access from pretix.work subdomains

commit fef1e356f7
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:33:24 2026 +0100

    fix out-of-the-box experience

commit 81775f5d2d
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:33:24 2026 +0100

    setup questionnaires vue app, add code from question editor proof of concept

commit 4bbcc398cc
Merge: a924d0a266 58840a5fd6
Author: Mira Weller <weller@rami.io>
Date:   Thu Mar 19 13:13:32 2026 +0100

    Merge remote-tracking branch 'refs/remotes/origin/master' into questions-vue3
2026-08-07 21:49:47 +02:00

152 lines
5.1 KiB
TypeScript

// vite build config for control UI
// widget has its own config, see src/pretix/static/pretixpresale/widget/vite.config.ts
import { defineConfig, type Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
import { parse as parseToml } from 'smol-toml'
// Shared dependencies exposed to plugins via import map.
// Adding a dep here auto-generates a _vendor/{name} entry and
// makes it available in the import map.
const SHARED_DEPS = ['vue']
const { entries: pretixPluginEntries } = discoverPretixPlugins()
const pluginDirs = [...new Set(Object.values(pretixPluginEntries).map(p => path.dirname(p)))]
export default defineConfig({
plugins: [
vue(),
sharedDepsPlugin(),
pretixPluginDevEntries(),
],
resolve: {
// Pin shared deps to pretix's node_modules to prevent duplicate instances
// across plugins whose node_modules live in sibling directories
dedupe: [...SHARED_DEPS, '@vue/runtime-core', '@vue/reactivity', '@vue/shared'],
},
server: {
fs: {
// Allow serving source files from sibling plugin directories
allow: ['src', ...pluginDirs],
},
cors: { origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\]|[^:]+\.pretix\.work)(?::\d+)?$/ },
},
build: {
manifest: true,
outDir: path.resolve(__dirname, 'src/pretix/static.dist/vite/control'),
rollupOptions: {
preserveEntrySignatures: 'exports-only',
input: {
'webcheckin/main': path.resolve(__dirname, 'src/pretix/plugins/webcheckin/static/pretixplugins/webcheckin/main.ts'),
'checkinrules/main': path.resolve(__dirname, 'src/pretix/static/pretixcontrol/js/ui/checkinrules/index.ts'),
...Object.fromEntries(SHARED_DEPS.map(dep => [`_vendor/${dep}`, `virtual:vendor/${dep}`])),
...pretixPluginEntries,
},
}
},
optimizeDeps: {
exclude: ['moment', 'jquery']
},
})
// Virtual module plugin: generates re-export entries for each shared dep
// In dev mode, serves /__pretix_importmap so the python template tag can build the import map without hardcoding dep names.
function sharedDepsPlugin (): Plugin {
const PREFIX = 'virtual:vendor/'
const RESOLVED = '\0virtual:vendor/'
return {
name: 'pretix-shared-deps',
resolveId (id) {
if (id.startsWith(PREFIX))
return RESOLVED + id.slice(PREFIX.length)
},
load (id) {
if (id.startsWith(RESOLVED)) {
const pkg = id.slice(RESOLVED.length)
return `export * from '${pkg}'`
}
},
// Serve the import map data so the Python template tag can fetch it in dev mode
configureServer (server) {
server.middlewares.use((req, res, next) => {
if (req.url === '/__pretix_importmap') {
const imports = Object.fromEntries(
SHARED_DEPS.map(dep => [
dep,
`/node_modules/.vite/deps/${dep.replace('/', '_')}.js`,
])
)
res.setHeader('Content-Type', 'application/json')
res.setHeader('Access-Control-Allow-Origin', '*')
res.end(JSON.stringify(imports))
return
}
next()
})
},
}
}
// TODO move to separate file?
function discoverPretixPlugins (): { entries: Record<string, string> } {
let manifestFiles: string[] = []
try {
const raw = execSync(`python -c "
import importlib_metadata as metadata, json, pathlib, tomllib
result = []
for ep in metadata.entry_points(group='pretix.plugin'):
dist = ep.dist
if not dist: continue
try:
url_info = json.loads(dist.read_text('direct_url.json') or '{}')
if not url_info.get('dir_info', {}).get('editable'):
continue # non-editable plugins build their own assets
p = pathlib.Path(url_info['url'].replace('file://', '')) / 'pretixplugin.toml'
if not p.exists():
continue
with p.open('rb') as f:
if 'vite' in tomllib.load(f):
result.append(str(p))
except Exception:
pass
print(json.dumps(result))
"`, { stdio: ['pipe', 'pipe', 'inherit'] }).toString().trim()
manifestFiles = JSON.parse(raw)
} catch (error) {
console.error('Failed to discover pretix plugins, skipping plugin entries:', error)
}
const entries: Record<string, string> = {}
for (const manifestFile of manifestFiles) {
const packageRoot = manifestFile.replace(/[/\\]pretixplugin\.toml$/, '')
const parsed = parseToml(readFileSync(manifestFile, 'utf8')) as {
vite: { entries: Record<string, string> }
}
for (const [name, rel] of Object.entries(parsed.vite.entries)) {
entries[name] = path.join(packageRoot, rel)
}
}
return { entries }
}
// In dev mode, the browser requests /{entryName} from the Vite dev server.
// Vite can't find these files since they live outside the project root.
// This plugin rewrites those URLs to /@fs{absPath} so Vite serves them directly.
function pretixPluginDevEntries (): Plugin {
return {
name: 'pretix-plugin-dev-entries',
configureServer (server) {
server.middlewares.use((req, _res, next) => {
const urlPath = req.url?.split('?')[0]
if (urlPath) {
const name = urlPath.slice(1) // strip leading /
if (name in pretixPluginEntries)
req.url = `/@fs${pretixPluginEntries[name]}`
}
next()
})
},
}
}