FredKSchott / snowpack

ESM-powered frontend build tool. Instant, lightweight, unbundled development. ✌️
https://www.snowpack.dev
MIT License
19.48k stars 921 forks source link

[BUG] snowback build looks for certificate when devOptions.secure = true #3051

Open neil-novatech opened 3 years ago

neil-novatech commented 3 years ago

Bug Report Quick Checklist

Describe the bug

After upgrading from 3.0.13 to 3.1.0 (and above, through 3.1.2), snowpack build fails when devOptions: { secure: true } is set is snowpack.config.js.

Example error:

yarn run v1.22.0
warning package.json: No license field
$ snowpack build
[11:42:55] [snowpack] ✘ No HTTPS credentials found!
[11:42:55] [snowpack] You can specify HTTPS credentials via either:

  - Including credentials in your project config under devOptions.secure.
  - Including snowpack.crt and snowpack.key files in your project's root directory.

    You can automatically generate credentials for your project via either:

  - devcert: npx devcert-cli generate localhost
    https://github.com/davewasmer/devcert-cli (no install required)

  - mkcert: mkcert -install && mkcert -key-file snowpack.key -cert-file snowpack.crt localhost
    https://github.com/FiloSottile/mkcert (install required)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce

We can't fix bugs that we can't see for ourselves. Issues often need to be closed if this section is skipped.

  1. npm init snowpack-app --template @snowpack/app-template-react --target secure
  2. set secure: true in devOptions block in snowpack.config.js
  3. yarn
  4. yarn upgrade snowpack@3.0.13
  5. yarn build
  6. success!
  7. yarn upgrade snowpack@3.1.0
  8. yarn build
  9. See error! [snowpack] ✘ No HTTPS credentials found! ...

Expected behavior

I expect snowpack build to succeed without checking for snowpack.key and snowpack.crt.

Anything else?

It looks like the following PR introduced this behavior while refactoring the build script to reuse the dev server: https://github.com/snowpackjs/snowpack/pull/2707

msokk commented 3 years ago

Still an issue in 3.4.0, for a quick workaround, one can use some env variable in config, for example: secure: !process.env.CI

bdashrad commented 2 years ago

Happens on us on 3.8.2 as well