nklayman / vue-cli-plugin-electron-builder

Easily Build Your Vue.js App For Desktop With Electron
https://nklayman.github.io/vue-cli-plugin-electron-builder/
MIT License
4.12k stars 278 forks source link

Cannot build with `test` mode #1627

Open undergroundwires opened 2 years ago

undergroundwires commented 2 years ago

Tested using

Both fails with:

 ERROR  WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.mode should be one of these:
   "development" | "production" | "none"
   -> Enable production optimizations or development hints.
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.mode should be one of these:
   "development" | "production" | "none"
   -> Enable production optimizations or development hints.
    at webpack (/home/bob/user/dev/undergroundwires/privacy.sexy/node_modules/webpack/lib/webpack.js:31:9)
    at bundleMain (/home/bob/user/dev/undergroundwires/privacy.sexy/node_modules/vue-cli-plugin-electron-builder/index.js:699:17)
    at /home/bob/user/dev/undergroundwires/privacy.sexy/node_modules/vue-cli-plugin-electron-builder/index.js:180:49
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

However they're officially supported Vue modes https://cli.vuejs.org/guide/mode-and-env.html and should be supported with vue-cli-plugin-electron-builder too. Maybe we could separate what's being sent to Vue to build and what we use as NODE_ENV to build?

It could also resolve #1626.

I believe it's reproducible with any repository, but I tested with privacy.sexy:

  1. git clone https://github.com/undergroundwires/privacy.sexy.git
  2. git checkout 0.11.3 (because master is subject to change`
  3. Run any of commands mentioned here.
nklayman commented 2 years ago

NODE_ENV is used to set the webpack mode. What's causing the issue is that --mode test sets NODE_ENV to test as well which webpack doesn't like. I'll fix this in v3, and I can backport it to v2 and release a hotfix if you need it. You can also create a .env.test file with NODE_ENV=production to fix this.

undergroundwires commented 2 years ago

Thanks. Happy to see you back. You're empowering majority of Vue desktop ecosystem behind the scenes and your work is much appreciated.