Closed luca-peruzzo closed 1 month ago
it happens also when running bin/vite build --ssr
manually after the production build:
Skipping vite build. Watched files have not changed since the last build at 2024-07-21 16:43:05`
Hi Luca!
The SSR build uses a different file to track whether the last build is stale or not.
Running a non-SSR build should not affect that check.
To confirm whether this is a bug or not, I'd appreciate if you could provide a repo with a minimal reproduction, demonstrating the problem.
I will as soon as possible!
@ElMassimo I have noticed that it only occurs when at least one build has been performed. Step to reproduce:
also deleting public/vite-dev causes the issue:
I think it is a systematic problem, so you can try with your demo repo. If you can't reproduce it i will give you access to my test repo
@ElMassimo I checked your code and I see that the cache is stored in tmp/cache/vite. Therefore, when a user deletes the output folder, the system cannot know if it should invalidate the cache. I'll try to add this functionality if you agree
The described replication steps fall within what I consider to be incorrect configuration.
Ensuring a proper strategy for managing buildCacheDir
in a way that's consistent with how the publicOutputDir
is managed, is up to the user.
This library provides a vite:clobber
task to use when intending to remove all previous builds, which will also clear buildCacheDir
.
"This library provides a vite:clobber task to use when intending to remove all previous builds, which will also clear buildCacheDir."
yes but you can easily track if the build output exists. something like:
def build_output_exists?(ssr:)
if ssr
Dir.exist? config.ssr_output_dir
else
Dir.exist? config.build_output_dir
end
end
and
def build(*args)
last_build = last_build_metadata(ssr: args.include?('--ssr'))
if args.delete('--force') || last_build.stale? || config.manifest_paths.empty? || !build_output_exists?(ssr: args.include?('--ssr'))
stdout, stderr, status = build_with_vite(*args)
log_build_result(stdout, stderr, status)
record_build_metadata(last_build, errors: stderr, success: status.success?)
status.success?
elsif last_build.success
logger.debug "Skipping vite build. Watched files have not changed since the last build at #{ last_build.timestamp }"
true
else
logger.error "Skipping vite build. Watched files have not changed since the build failed at #{ last_build.timestamp } โ"
false
end
end
I've done this modification locally and it works. if you agree I can reopen the pull request
bundle update vite_ruby
.Description ๐
When running
RAILS_ENV=production VITE_RUBY_SSR_BUILD_ENABLED=true bundle exec rake assets:precompile
only the vite client build is executed. the ssr build skips with this message:Skipping vite build. Watched files have not changed since the last build at <timestamp>
Vite Ruby Info
``` bin/vite present?: true vite_ruby: 3.6.0 vite_rails: 3.0.17 rails: 7.1.3.4 node: v20.11.1 npm: 10.2.4 yarn: 4.3.1 pnpm: Usage Error: This project is configured to use yarn $ pnpm ... ruby: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23] installed packages: app@ /Users/luca.peruzzo/RubymineProjects/react-on-rails โโโฌ @vitejs/plugin-react@4.3.1 โ โโโ vite@5.3.4 deduped โโโฌ vite-plugin-rails@0.5.0 โ โโโฌ vite-plugin-environment@1.1.3 โ โ โโโ vite@5.3.4 deduped โ โโโ vite-plugin-ruby@5.0.0 deduped โ โโโ vite@5.3.4 deduped โโโฌ vite-plugin-ruby@5.0.0 โ โโโ vite@5.3.4 deduped โโโ vite@5.3.4 ```Output
`RAILS_ENV=production VITE_RUBY_SSR_BUILD_ENABLED=true DEBUG=vite-plugin-ruby:* bundle exec rake assets:precompile` ``` โค YN0000: ยท Yarn 4.3.1 โค YN0000: โ Resolution step โค YN0000: โ Completed โค YN0000: โ Post-resolution validation โค YN0002: โ app@workspace:. doesn't provide postcss (pdac39), requested by autoprefixer and other dependencies. โค YN0086: โ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements