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