Open gbenson-ff opened 2 years ago
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
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:
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 myindex.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.