Issues with static files and ESBuild loader
ThiagoFacchini opened this issue · comments
Hello,
I'm having issues configuring esbuild-dev-server to work.
This is my current esBuildDevServer configuration:
esBuildDevServer.start(
build({
entryPoints: ['./index.tsx'],
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
platform: 'browser',
target: ['chrome58', 'safari11'],
loader: {
'.png': "file",
'.hdr': 'file',
'.jpg': 'file',
'.otf': 'file',
'.ttf': 'file'
},
plugins: [
stylePlugin({
postcss: {
plugins: [
postcssImport,
postcssNesting,
autoprefixer
]
}
}),
copyFilePlugin({
source: ['utils/reset.css'],
target: ['../../public/client/static'],
copyWithFolder: false
}),
svgPlugin()
],
outdir: '../../public/client/static'
}),
// To run the dev server a permission change is necessary:
// chmod u+x node_modules/esbuild-dev-server-darwin-x64/devserver
{
port: '8080',
watchDir: './',
index: '../../public/client/index.html',
staticDir: '../../public/client/',
onBeforeRebuild: {},
onAfterRebuild: {}
}
)
And this is my current file structure:
As you can see things are apparently in place, although when I open my application, the very first view tries to load the image (logo-DGF6IMCN.png), which fails because the path is wrong as the picture below shows:
I understand my files are going to this path due my outdir configuration right? If I change that parameter to '../../plublic/client', then the files get copied to the 'proper' path but the esbuild-dev-server understands any request on this path to be a route, so I'm kinda lost on how to configure it to work properly.
The only way I can currently get it to work is if I set the loader to data-url, which is far from be ideal.
Can you guys please advise?
Thanks
Anybody?
@ThiagoFacchini, take a look at #7, this may solve your issue (if you're still having it)