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

Issues with static files and ESBuild loader #9

Open
ThiagoFacchini opened this issue Oct 25, 2022 · 1 comment
Open

Issues with static files and ESBuild loader #9

ThiagoFacchini opened this issue Oct 25, 2022 · 1 comment

Comments

@ThiagoFacchini
Copy link

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:
Screen Shot 2022-10-25 at 11 41 58 am

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:
Screen Shot 2022-10-25 at 11 43 14 am

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

@ThiagoFacchini
Copy link
Author

Anybody?

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

1 participant