🐛 📺 fixes dev server

This commit is contained in:
2026-05-20 14:40:00 +02:00
parent 139b1590ce
commit 7d6240e28a
3 changed files with 59 additions and 34 deletions
+7 -5
View File
@@ -9,15 +9,17 @@ set -eo pipefail # this can be harmful, see https://www.youtube.com/watch?v=4Jo3
# depends on
declare -r server='node_modules/.bin/web-dev-server'
declare -r lint='bs/lint'
declare -r index='index.html'
declare -r server_config='web-dev-server.config.js'
help(){
if ! isHelp "${@}"; then return 0; fi
echoReadmeInfo
cat <<-EOF
Options:
./src Starts the development server (default)
./dist Starts the production server
Defaults:
See server config file: '$server_config'
EOF
$server --help
exit 0
@@ -26,12 +28,12 @@ main(){
help "${@}"
local -r target="${1:-./src}" # ./src or ./dist
if [[ "$target" == './dist' ]]; then
if [[ "$target" =~ 'dist' ]]; then
# console warns because of config file, use npx serve?
$server --root-dir "$target" --app-index $index --open
$server "${@}"
else
$lint --watch --preserveWatchOutput &
$server &
$server "${@}" &
wait
fi
}
+21 -4
View File
@@ -1,21 +1,38 @@
{
"compilerOptions": {
"verbatimModuleSyntax": true,
"noEmitOnError": true,
"target": "es2021",
"skipLibCheck": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noEmitOnError": true,
"lib": ["es2021", "dom", "DOM.Iterable"],
"isolatedModules": true,
"strict": true,
"strictBindCallApply": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noUncheckedSideEffectImports": true,
"allowUnreachableCode": false,
"noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"erasableSyntaxOnly": true,
"noImplicitOverride": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": false,
"experimentalDecorators": true,
"importHelpers": true,
"noErrorTruncation": false,
"outDir": "out-tsc",
"sourceMap": true,
"inlineSources": true,
"rootDir": "./",
"incremental": true,
"skipLibCheck": true,
"types": ["mocha"]
"types": ["mocha"],
"lib": ["es2021", "dom", "DOM.Iterable"]
},
"include": ["**/*.ts"]
}
+16 -10
View File
@@ -1,21 +1,27 @@
// import { hmrPlugin, presets } from "@open-wc/dev-server-hmr";
/** Use Hot Module replacement by adding --hmr to the start command */
const hmr = process.argv.includes("--hmr");
/** Use Hot Module replacement by adding --watch to the start command */
//const hmr = process.argv.includes("--watch");
const [ mode ] = process.argv.slice(2);
const target = mode === "src" // OR "dist"
? {
rootDir: ".",
appIndex: "./index.html",
}
: {
rootDir: "./dist",
appIndex: "./dist/index.html",
};
export default /** @type {import("@web/dev-server").DevServerConfig} */ ({
open: "/",
watch: !hmr,
/** Resolve bare module imports */
nodeResolve: {
open: "/", // SPA routing
nodeResolve: { // Resolve bare module imports
exportConditions: ["browser", "development"],
},
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
// esbuildTarget: "auto"
// esbuildTarget: "auto" // Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
/** Set appIndex to enable SPA routing */
appIndex: "./index.html",
...target,
plugins: [
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */