local authentication placeholder
This commit is contained in:
parent
8169e280ec
commit
3b62d87d31
6 changed files with 105 additions and 17 deletions
|
|
@ -8,14 +8,15 @@ import { fileURLToPath } from 'node:url'
|
|||
|
||||
const rootDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const NO_CRISP_MODE = 'nocrisp'
|
||||
const LOCALNET_MODE = 'localnet'
|
||||
|
||||
function useNoCrispIndexHtml (mode: string, command: string): Plugin {
|
||||
if (mode !== NO_CRISP_MODE || command !== 'serve') {
|
||||
return { name: 'use-local-index-html-noop' }
|
||||
/** Dev server: serve the minimal LAN shell (indexLocal.html) instead of the full index with third-party bootstraps. */
|
||||
function useLocalnetShellHtml (mode: string, command: string): Plugin {
|
||||
if (mode !== LOCALNET_MODE || command !== 'serve') {
|
||||
return { name: 'localnet-shell-html-noop' }
|
||||
}
|
||||
return {
|
||||
name: 'use-local-index-html',
|
||||
name: 'localnet-shell-html',
|
||||
apply: 'serve',
|
||||
transformIndexHtml: {
|
||||
order: 'pre',
|
||||
|
|
@ -26,12 +27,13 @@ function useNoCrispIndexHtml (mode: string, command: string): Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
function emitNoCrispIndexAsIndexHtml (mode: string): Plugin {
|
||||
if (mode !== NO_CRISP_MODE) {
|
||||
return { name: 'emit-nocrisp-index-as-index-noop' }
|
||||
/** After build, LAN shell is emitted as indexLocal.html; rename to index.html so nginx and PWA still use /. */
|
||||
function emitLocalnetShellAsIndexHtml (mode: string): Plugin {
|
||||
if (mode !== LOCALNET_MODE) {
|
||||
return { name: 'emit-localnet-shell-as-index-noop' }
|
||||
}
|
||||
return {
|
||||
name: 'emit-nocrisp-index-as-index-html',
|
||||
name: 'emit-localnet-shell-as-index-html',
|
||||
closeBundle () {
|
||||
const outDir = path.join(rootDir, 'build')
|
||||
const from = path.join(outDir, 'indexLocal.html')
|
||||
|
|
@ -46,11 +48,11 @@ function emitNoCrispIndexAsIndexHtml (mode: string): Plugin {
|
|||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ command, mode }): UserConfig => {
|
||||
const useNoCrispIndex = mode === NO_CRISP_MODE
|
||||
const useLocalnetShell = mode === LOCALNET_MODE
|
||||
return {
|
||||
plugins: [
|
||||
useNoCrispIndexHtml(mode, command),
|
||||
emitNoCrispIndexAsIndexHtml(mode),
|
||||
useLocalnetShellHtml(mode, command),
|
||||
emitLocalnetShellAsIndexHtml(mode),
|
||||
react(),
|
||||
tsconfigPaths(),
|
||||
VitePWA({
|
||||
|
|
@ -99,7 +101,7 @@ export default defineConfig(({ command, mode }): UserConfig => {
|
|||
input: {
|
||||
main: path.join(
|
||||
rootDir,
|
||||
useNoCrispIndex ? 'indexLocal.html' : 'index.html'
|
||||
useLocalnetShell ? 'indexLocal.html' : 'index.html'
|
||||
),
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue