open-wc-starter-app
open-wc-starter-app copied to clipboard
Problem with a SPA and owc-dev-server (--app-index)
I'm having troubles using the default start script in package.json.
The default one is:
"start": "owc-dev-server --open ./src"
but I'm building a SPA (single page application) and I changed it to:
"start": "owc-dev-server --app-index ./src/index.html"
adding also in index.html's <head>:
<base href="/">
But now the problem is:
<script type="module" src="./my-app.js"></script>
In browser's console I got this error:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
I need to change it like this to work:
<script type="module" src="./src/my-app.js"></script>
adding ./src before /my-app.js.
The problem now is using npm run build: it doesn't find my-app.js during build.
I'm wrong somewhere, but where?