@@ -18,31 +18,30 @@ import extra_css from './ui/extra-css';
1818import stylelint from 'stylelint' ;
1919import stylelintrc from './ui/stylelintrc.cjs' ;
2020import postcssReporter from "postcss-reporter" ;
21-
2221const BUILDDIR = path . resolve ( process . env . BUILDDIR || 'out/' ) ;
2322const gen_path = path . resolve ( BUILDDIR + "/gen/" ) ;
23+ const __VITE_CONFIG__ = JSON . parse ( fs . readFileSync ( path . resolve ( BUILDDIR + "/version.json" ) , 'utf8' ) ) ;
24+ const __DEV__ = __VITE_CONFIG__ . __DEV__ ;
2425// Note: For development, ports are hard coded, synchronize port numbers with serve.sh
25- const DEVPORT_ANKLANG = process . env . DEVPORT_ANKLANG || 1776 ;
2626const DEVPORT_VITE = process . env . DEVPORT_VITE || 1777 ;
27- const DEVPORT_MKDOCS = process . env . DEVPORT_MKDOCS || 1778 ;
27+ const DEVPORT_ANKLANG = process . env . DEVPORT_ANKLANG || 0 ;
28+ const DEVPORT_MKDOCS = process . env . DEVPORT_MKDOCS || 0 ;
2829
2930// Debug Info:
3031console . log ( `VITE: CWD=${ process . cwd ( ) } BUILDDIR=${ BUILDDIR } gen_path=${ gen_path } ` ) ;
3132
3233// Plugin to inject __VITE_CONFIG__ into html
33- const html_inject_vite_config = ( __DEV__ : Boolean ) => {
34- build_config_json . __DEV__ = __DEV__ ;
35- if ( __DEV__ ) {
36- build_config_json . ws_port = DEVPORT_ANKLANG ;
34+ const html_inject_vite_config = ( ) => {
35+ if ( __DEV__ && DEVPORT_ANKLANG ) {
36+ __VITE_CONFIG__ . ws_port = DEVPORT_ANKLANG ;
3737 }
3838 return {
3939 name : 'html_inject_vite_config' ,
4040 transformIndexHtml ( html , ctx ) {
41- return html . replace ( '__VITE_CONFIG__' , JSON . stringify ( build_config_json ) ) ;
41+ return html . replace ( '__VITE_CONFIG__' , JSON . stringify ( __VITE_CONFIG__ ) ) ;
4242 } ,
4343 }
4444} ;
45- const build_config_json = JSON . parse ( fs . readFileSync ( path . resolve ( BUILDDIR + "/version.json" ) , 'utf8' ) ) ;
4645
4746// Plugin to force full reloads if anything changed
4847const full_reload_always : PluginOption = {
@@ -73,7 +72,6 @@ function postcss_formatter (input)
7372// Mode dependent vite config
7473function vite_config ( { mode } )
7574{
76- const __DEV__ = mode == 'development' ;
7775 console . log ( `VITE: mode=${ mode } ` ) ;
7876 return defineConfig ( {
7977 root : "ui/" ,
@@ -84,7 +82,7 @@ function vite_config ({ mode })
8482 } , } ,
8583 server : {
8684 // open: "index.html",
87- proxy : {
85+ proxy : ! DEVPORT_MKDOCS ? { } : {
8886 '/anklang/' : {
8987 target : 'http://localhost:' + String ( DEVPORT_MKDOCS ) + '/' ,
9088 changeOrigin : true , // Adjusts the origin header
@@ -130,7 +128,7 @@ function vite_config ({ mode })
130128 tailwindcss ( ) ,
131129 extra_css ( ) ,
132130 solidPlugin ( ) ,
133- html_inject_vite_config ( __DEV__ ) ,
131+ html_inject_vite_config ( ) ,
134132 ...maybe_full_reload_always ,
135133 ] ,
136134
0 commit comments