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

Task/upgrade to rails 8 #265

Merged
merged 2 commits into from
Dec 14, 2024
Merged

Task/upgrade to rails 8 #265

merged 2 commits into from
Dec 14, 2024

Conversation

leesheppard
Copy link
Member

Upgrade from 7.2 to 8.0

@leesheppard leesheppard self-assigned this Dec 11, 2024
@leesheppard leesheppard linked an issue Dec 11, 2024 that may be closed by this pull request
@leesheppard leesheppard merged commit 3da6d84 into main Dec 14, 2024
2 checks passed
@gamesover
Copy link
Contributor

After upgrading to Rails 8, Webpacker is encountering issues in the development environment.

ubuntu@code-server:~/projects/ruby_au$ yarn start
yarn run v1.22.22
$ NODE_OPTIONS=--openssl-legacy-provider bin/webpack-dev-server
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'https'. These properties are valid:
   object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, ipc?, liveReload?, onListening?, open?, port?, proxy?, server?, app?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

remove https: false from config/webpacker.yml does not help.

I think we need to implement #204 ticket.

For now, we can run rails assets:precompile in development to get latest frontend assets

@leesheppard
Copy link
Member Author

Currently working in a branch to replace Webpacker at present with Vite.

@leesheppard
Copy link
Member Author

@gamesover I've now got a PR in place for Vite to take over

@gamesover
Copy link
Contributor

Fantastic work, @leesheppard!
Thank you so much for your swift action.

A bit off-topic – I know this project doesn’t require PDF generation, but I came across this article discussing the migration from Webpacker to Vite.

One major drawback of Vite is that wkhtmltopdf can no longer generate styled PDFs. While this isn’t an issue for this project, future projects requiring styled PDFs would need to migrate to Puppeteer or similar alternatives (see GitHub discussion).

Wicked_PDF and wkhtmltopdf are widely used in many Ruby on Rails projects. If Vite doesn’t support them, it could become a significant challenge.

In such cases, do you know of any workarounds or alternative libraries that support wkhtmltopdf? Or would you recommend alternatives to Vite that maintain compatibility with wkhtmltopdf?

Appreciate any insights you might have!

@leesheppard
Copy link
Member Author

@gamesover There’s no fundamental incompatibility between Vite and WickedPDF, only the need to configure asset references so that the PDF generator can do its job correctly. It comes down to how you reference static assets so that wkhtmltopdf can properly find them. Ensuring that your PDF-generating views (or layouts) use either:

  • Fully compiled (production) paths for CSS/JS/images
  • A separate minimal set of inline or absolute-file paths

As mentioned above, the common workaround is to ensure your PDF views reference compiled assets rather than the dev server. In other words, you generate your PDF against the production-bundled assets in public/vite/assets

@gamesover
Copy link
Contributor

@gamesover There’s no fundamental incompatibility between Vite and WickedPDF, only the need to configure asset references so that the PDF generator can do its job correctly. It comes down to how you reference static assets so that wkhtmltopdf can properly find them. Ensuring that your PDF-generating views (or layouts) use either:

  • Fully compiled (production) paths for CSS/JS/images
  • A separate minimal set of inline or absolute-file paths

As mentioned above, the common workaround is to ensure your PDF views reference compiled assets rather than the dev server. In other words, you generate your PDF against the production-bundled assets in public/vite/assets

Thanks for your advice. If so, Vite is a perfect solution to me.

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.

Upgrade to Rails 8
2 participants