Wrangler: allow custom webpack config for Workers Sites projects

Created on 25 Nov 2019  ·  7Comments  ·  Source: cloudflare/wrangler

$ wrangler build
⚠️  Workers Sites does not support custom webpack configuration files
✨  Built successfully, built project size is 11 KiB.

Thsi error message is historical; when wrangler implicitly looked at the root for a custom webpack config, it made sense to disable the functionality for sites since the root would likely contain a config for the app you were deploying, not for the workers site. with this change, though, we should allow custom webpack configs since you are required to declare them in your wrangler.toml. This should be as simple as removing a conditional somewhere in wranglerjs, we just need to triage it.

_Originally posted by @ashleymichal in https://github.com/cloudflare/wrangler/pull/847#issuecomment-558234664_

category - feature good first issue status - PR welcome subject - site

Most helpful comment

That's correct @darrenhebner - you can also build from master using rust with cargo install --git "https://github.com/cloudflare/wrangler" --force (you may need to npm uninstall -g @cloudflare/wrangler if you previously installed with that)

All 7 comments

please correct me (never wrote any rust) but it looks like it's not just the warning which is wrong:

https://github.com/cloudflare/wrangler/blob/master/src/commands/build/wranglerjs/mod.rs#L177

    let custom_webpack_config_path = match &target.webpack_config {
        Some(webpack_config) => match &target.site {
            None => Some(PathBuf::from(&webpack_config)),
            Some(_) => {
                message::warn("Workers Sites does not support custom webpack configuration files");
                None
            }
        },

if webpack is given and worker site is activated then custom_webpack_config_path will be set to None.

this is the opposite of what the docs are stating:

... If you are using Workers Sites and want to specify your own webpack configuration, you will always need to specify this ...

https://developers.cloudflare.com/workers/tooling/wrangler/webpack/

that's a good catch! i'll assign this to me and tackle it friday. sorry for the mismatch, we'll patch it up asap.

Hello! It looks like this issue was fixed in #957, but I'm still seeing the error when attempting to publish a Workers Site with a custom webpack config.

I'm using Wrangler 1.6.0. I'm guessing we just need to wait for a new release?

That's correct @darrenhebner - you can also build from master using rust with cargo install --git "https://github.com/cloudflare/wrangler" --force (you may need to npm uninstall -g @cloudflare/wrangler if you previously installed with that)

Is there any ETA for this to be published to npm? It's preventing using https://github.com/cloudflare/wrangler-action with a custom Workers Sites webpack config, and I'd rather not have to fork the wrangler action if at all possible!

Why is this closed? Still seeing this issue

@acoyfellow You might have to add context: __dirname, to your custom webpack config as I did.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GregBrimble picture GregBrimble  ·  6Comments

nickbalestra picture nickbalestra  ·  5Comments

simplenotezy picture simplenotezy  ·  5Comments

tibotiber picture tibotiber  ·  6Comments

shyim picture shyim  ·  5Comments