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

Avoid dist directory cluttering when running unit tests #398

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

sronveaux
Copy link
Collaborator

This PR changes the configuration in vue.config.js when in test mode to avoid an unsuitable behaviour introduced, apparently, when updating to Vue-CLI 3...

For now, when you run the unit tests, karma-webpack outputs the results in the dist directory, potentially destroying your latest build and adding some files only related to tests (common.js and runtime.js).

The reason is that when Vue-CLI 2 was used, Karma was one of the test runners recommended by Vue, so configuration was adapted for it. If you go back in time, you'll see that webpack configuration was almost empty in test mode compared to dev mode.
In Vue-CLI, the recommended test runner was mochapack which works completely differently. But most important, as stated in their documentation, it is written in a way that nothing is ever written on the disk by webpack, all stays is memory.

So there are two tweaks made by this PR in the config file:

  1. Remove the unneeded plugins from webpack configuration in order to behave closer to like it was in Vue-CLI 2
  2. Remove the config.output.path so default value of karma-webpack is taken, effectively outputting the build inside a temporary directory

Copy link
Collaborator

@chrismayer chrismayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this @sronveaux. Tested and works as expected 👍

Please merge at will...

@sronveaux sronveaux merged commit b15e968 into wegue-oss:master Jun 6, 2024
1 check passed
@sronveaux sronveaux deleted the karma-webpack-build-config branch June 6, 2024 14:47
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

Successfully merging this pull request may close these issues.

2 participants