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

Build and build -w output differs #594

Closed
draotth opened this issue Aug 18, 2023 · 6 comments
Closed

Build and build -w output differs #594

draotth opened this issue Aug 18, 2023 · 6 comments

Comments

@draotth
Copy link
Contributor

draotth commented Aug 18, 2023

Problem

The outputted images for vite build -w have the /@imagetools/* reference, which consumers of my library cannot interpret or find.

My workaround

Running build (no watch) with chokidar to publish updates to calc locally works, but has it's own problems (e.g. production build, no HMR, etc).

I statically copy the images from the npm package (I'm using chokidar/yalc to publish the changes when the dist folder of the Component Lib changes).

Possible solutions

  1. Change (or allow configuration of) imagetools to output
  2. Let me know the location of the /@imagetools files, and I can try to see if I can manually copy those in dev mode.
@benmccann
Copy link
Collaborator

That's probably coming from this line:

if (this.meta.watchMode) {

That line should probably be updated to check if we're in build mode or dev mode instead. I don't know that I'll get to this for awhile, but a PR would be welcome. I can review and merge quickly if you'd like to take stab at it

@draotth
Copy link
Contributor Author

draotth commented Aug 18, 2023

Switched to use viteConfig.isProduction, which has the following values:

  1. vite build - true
  2. vite build -w - true
  3. vite dev - false

However, the unit tests using the Javascript API seem to have this as always false, even if you set mode: 'production'

This, of course, breaks the output paths for all the tests. Any thoughts off-hand?

@draotth
Copy link
Contributor Author

draotth commented Aug 18, 2023

This is because NODE_ENV is set while unit testing to production.

This leads me to think that isProduction is less reliable for this and perhaps other unknown reasons.

(viteConfig.command !== 'build') seems much more reliable for the use case here.

@draotth
Copy link
Contributor Author

draotth commented Aug 18, 2023

Created a PR

@benmccann
Copy link
Collaborator

Thank you for the fix! #595

@draotth
Copy link
Contributor Author

draotth commented Aug 18, 2023

Thanks for the fast responses!

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

2 participants