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

Migrate JavaScript and Stylesheets to esbuild #95

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
# Ignore master key for decrypting credentials and more.
/config/master.key

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity

/app/assets/builds/*
!/app/assets/builds/.keep
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.15.0
22.11.0
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ gem 'puma', '~> 5'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'

# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.4.0'
# Bundle and transpile JavaScript in Rails with esbuild, rollup.js, bun, or Webpack.
gem 'jsbundling-rails', '~> 1.3'

# The speed of a single-page web application without having to write any JavaScript
gem 'turbo-rails'
Expand Down
12 changes: 3 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ GEM
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
json (2.9.1)
language_server-protocol (3.17.0.3)
listen (3.8.0)
Expand Down Expand Up @@ -146,8 +148,6 @@ GEM
nio4r (~> 2.0)
racc (1.8.1)
rack (2.2.10)
rack-proxy (0.7.6)
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.7)
Expand Down Expand Up @@ -218,7 +218,6 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -262,11 +261,6 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webpacker (5.4.4)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket (1.2.9)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
Expand All @@ -283,6 +277,7 @@ DEPENDENCIES
byebug
capybara (>= 2.15)
ffaker (~> 2.14)
jsbundling-rails (~> 1.3)
listen (~> 3.2)
pg (>= 0.18, < 2.0)
puma (~> 5)
Expand All @@ -299,7 +294,6 @@ DEPENDENCIES
tzinfo-data
web-console (>= 3.3.0)
webdrivers
webpacker (~> 5.4.0)

RUBY VERSION
ruby 3.1.4p223
Expand Down
2 changes: 1 addition & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: rails s -p 3000
js: bin/webpack-dev-server
js: yarn build --watch
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* Stimulus 3.2
* StimulusReflex 3.5
* Turbo 7.2
* Webpacker 5
* Node 16
* esbuild via ([jsbundling-rails](https://github.com/rails/jsbundling-rails) and [esbuild-rails](https://github.com/excid3/esbuild-rails))
* Node 22
* Yarn 1
* PostgreSQL
* Redis
Expand Down
Empty file added app/assets/builds/.keep
Empty file.
2 changes: 1 addition & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../builds
19 changes: 0 additions & 19 deletions app/assets/stylesheets/application.css

This file was deleted.

5 changes: 5 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import './config'
import './channels'
import './controllers'

import './stylesheets/application.scss'
3 changes: 1 addition & 2 deletions app/javascript/channels/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Load all the channels within this directory and all subdirectories.
// Channel files must be named *_channel.js.

const channels = require.context('.', true, /_channel\.js$/)
channels.keys().forEach(channels)
import "./channels/**/*_channel.js"
7 changes: 4 additions & 3 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Controller files must be named *_controller.js.

import { application } from './application'
import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers'
import controllers from './**/*_controller.js'

const context = require.context('controllers', true, /_controller\.js$/)
application.load(definitionsFromContext(context))
controllers.forEach((controller) => {
application.register(controller.name, controller.module.default)
})
5 changes: 0 additions & 5 deletions app/javascript/packs/application.js

This file was deleted.

8 changes: 8 additions & 0 deletions app/javascript/stylesheets/_bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$primary: #44449b;
$secondary: lightgrey;
$success: #4fcb4a;
$info: #9ecdfa;

$breadcrumb-divider: quote(">");

@import 'bootstrap/scss/bootstrap';
12 changes: 5 additions & 7 deletions app/javascript/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
$primary: #44449b;
$secondary: lightgrey;
$success: #4fcb4a;
$info: #9ecdfa;
#app {
margin-bottom: 125px
}

$breadcrumb-divider: quote(">");

@import 'bootstrap/scss/bootstrap';
@import './bootstrap';
@import './folders';
3 changes: 1 addition & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
<%= content_tag :link, '', rel: 'shortcut icon', href: '/favicon.ico' %>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>
<%= stylesheet_pack_tag 'application', 'data-turbo-track': 'reload' %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/regular.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/solid.css">
Expand Down
10 changes: 6 additions & 4 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

if ! foreman version &> /dev/null
then
if gem list --no-installed --exact --silent foreman; then
echo "Installing foreman..."
gem install foreman
fi

foreman start -f Procfile.dev "$@"
# Default to port 3000 if not specified
export PORT="${PORT:-3000}"

exec foreman start -f Procfile.dev --env /dev/null "$@"
18 changes: 0 additions & 18 deletions bin/webpack

This file was deleted.

18 changes: 0 additions & 18 deletions bin/webpack-dev-server

This file was deleted.

5 changes: 0 additions & 5 deletions config/webpack/development.js

This file was deleted.

13 changes: 0 additions & 13 deletions config/webpack/environment.js

This file was deleted.

5 changes: 0 additions & 5 deletions config/webpack/production.js

This file was deleted.

5 changes: 0 additions & 5 deletions config/webpack/test.js

This file was deleted.

96 changes: 0 additions & 96 deletions config/webpacker.yml

This file was deleted.

Loading
Loading