Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All requests resolve to index.html #7

Open
gbenson-ff opened this issue Apr 15, 2022 · 2 comments
Open

All requests resolve to index.html #7

gbenson-ff opened this issue Apr 15, 2022 · 2 comments

Comments

@gbenson-ff
Copy link

I've got this plugin set up and running a dev server, however all network requests resolve to the index.html file. This includes requests for my index.js file, which of course fails.

Would you be able to help me figure this out? I can provide more info if you tell me what you need.

@ThePerryR
Copy link

As far as I can tell, any file in the root of your "dist" folder will be treated as a route, and not work as expected. (at least for JS files)
You will need to build your js into "dist/js" or something, then update index.html to request /js/xxxx.js

@ironkayman
Copy link

ironkayman commented Aug 9, 2022

Setting very specific staticDir seems to work, I serve index.html with relative css stylesheets from node_modules, with staticDir: "dist" somewhy there are correcty imported as css, same issue was with every other .js, as it was replaced with index.html. Also, i still encounter failed font imports, they have the same paths from node_modules as css, while second is delivered just fine...

esbuild.config.js:

esBuildDevServer.start(
	build({
		entryPoints: ["src/index.ts", "dist/index.html"],
		outdir: "dist/final",
		incremental: true,
        loader: {
            ".html": "text",
            ".ts": "ts",
        },
        bundle: true,
	}),
	{
		port:      "8080",
		watchDir:  "src",
		index:     "dist/index.html",
		staticDir: "dist",
	}
)

index.html has this scripts apart from ../node_modules/...:

<script type="text/javascript" src="/final/dist/index.js"></script>
<script type="text/javascript" src="/final/src/index.js"></script>

Directory tree:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants