Closed ksol closed 8 months ago
As a proof of concept, I tried to add bun/npm/yarn support to the generators in a separate branch. It seems working as intended, but as there is no specs... Can't be sure. It can be checked at https://github.com/rails/jsbundling-rails/compare/main...ksol:jsbundling-rails:feat/task-npm-support-2
If anyone got here trying to make --watch work, this is what I got for esbuild and tailwind:
package.json:
"scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
"build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css --minify"
},
Procfile.dev
web: bin/rails server
js: npm run build -- --watch
css: npm run build:css -- --watch
Fixes partly #176.
At my company, we're moving away from yarn as it does not bring a lot of value in our use cases and we'd rather stick with the defaults, but this gem assumes/requires yarn.
This PR falls back on
npm
for installing packages + running the build script in bun/yarn is not present.This PR does not (yet) add
npm
support for the generators (Procfile.dev, etc) however; should I add it here and take inspiration from the Bun PR ?