Skip to content

Commit

Permalink
bring back esbuild and remove Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed Feb 25, 2024
1 parent ef7c45c commit 4803575
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 511 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/javascript/controllers/index.js
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: linters
name: CI

on:
pull_request:
Expand All @@ -7,6 +7,8 @@ on:
push:
branches:
- main
- ga-mrsk
- bring-back-esbuild

concurrency: ci-${{ github.ref }}

Expand Down Expand Up @@ -61,8 +63,11 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build assets
run: bin/vite build --clear --mode=test
- name: Build css assets
run: yarn build:css

- name: Build js assets
run: yarn build

- name: Prepare database
run: |
Expand All @@ -73,6 +78,5 @@ jobs:
run: |
bin/rails test
bin/rails test:system
# - name: Smoke test database seeds
# run: sudo bin/rails db:reset
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ RUN bundle exec bootsnap precompile app/ lib/
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


# Final stage for app image
FROM base

Expand Down
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ gem "puma"
gem "jbuilder"

# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
# gem "jsbundling-rails"
gem "jsbundling-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
# gem "stimulus-rails"
gem "stimulus-rails"

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
# gem "cssbundling-rails"
gem "cssbundling-rails"

# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"
Expand Down Expand Up @@ -90,7 +90,6 @@ gem "inline_svg", "~> 1.9"
gem "net-http", "~> 0.3.2"
gem "meilisearch-rails", "~> 0.9.1"
gem "ahoy_matey", "~> 4.2"
gem "vite_rails"
gem "meta-tags", "~> 2.18"

gem "groupdate", "~> 6.2"
Expand Down
32 changes: 19 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ GEM
bigdecimal
rexml
crass (1.0.6)
cssbundling-rails (1.4.0)
railties (>= 6.0.0)
date (3.3.4)
debug (1.9.1)
irb (~> 1.10)
Expand All @@ -132,7 +134,6 @@ GEM
railties (>= 6.1)
drb (2.2.0)
ruby2_keywords
dry-cli (1.0.0)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
Expand Down Expand Up @@ -188,6 +189,8 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jsbundling-rails (1.3.0)
railties (>= 6.0.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
Expand Down Expand Up @@ -234,8 +237,12 @@ GEM
nio4r (2.7.0)
nokogiri (1.16.2-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.2-arm-linux)
racc (~> 1.4)
nokogiri (1.16.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86-linux)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
Expand All @@ -262,8 +269,6 @@ GEM
rack (3.0.9.1)
rack-mini-profiler (3.3.1)
rack (>= 1.2.0)
rack-proxy (0.7.7)
rack
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -356,7 +361,9 @@ GEM
smart_properties (1.17.0)
sorbet-runtime (0.5.11267)
sqlite3 (1.7.2-aarch64-linux)
sqlite3 (1.7.2-arm-linux)
sqlite3 (1.7.2-arm64-darwin)
sqlite3 (1.7.2-x86-linux)
sqlite3 (1.7.2-x86_64-darwin)
sqlite3 (1.7.2-x86_64-linux)
standard (1.34.0)
Expand All @@ -373,6 +380,8 @@ GEM
rubocop-performance (~> 1.20.2)
standardrb (1.0.1)
standard
stimulus-rails (1.3.3)
railties (>= 6.0.0)
stringio (3.1.0)
thor (1.3.0)
tilt (2.3.0)
Expand All @@ -392,13 +401,6 @@ GEM
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
vite_rails (3.0.17)
railties (>= 5.1, < 8)
vite_ruby (~> 3.0, >= 3.2.2)
vite_ruby (3.5.0)
dry-cli (>= 0.7, < 2)
rack-proxy (~> 0.6, >= 0.6.1)
zeitwerk (~> 2.2)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -419,8 +421,10 @@ GEM

PLATFORMS
aarch64-linux
arm64-darwin-22
x86_64-darwin-19
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux

DEPENDENCIES
Expand All @@ -433,6 +437,7 @@ DEPENDENCIES
byebug (~> 11.1)
capybara
chartkick (~> 5.0)
cssbundling-rails
debug
dockerfile-rails (>= 1.2)
dotenv-rails
Expand All @@ -443,6 +448,7 @@ DEPENDENCIES
groupdate (~> 6.2)
inline_svg (~> 1.9)
jbuilder
jsbundling-rails
litestack
meilisearch-rails (~> 0.9.1)
meta-tags (~> 2.18)
Expand All @@ -459,11 +465,11 @@ DEPENDENCIES
selenium-webdriver
sitemap_generator (~> 6.3)
standardrb (~> 1.0)
stimulus-rails
turbo-rails
tzinfo-data
vcr (~> 6.1)
view_component (~> 3.7)
vite_rails
web-console
webmock

Expand Down
5 changes: 3 additions & 2 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
web: bin/rails server -p 3000
vite: bin/vite dev
web: unset PORT && bin/rails server
js: yarn build --watch
css: yarn build:css --watch
search: meilisearch
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
@import "components/transition.css";
@import "components/typography.css";
@import "components/video.css";

@import "vendors/vlitejs";
1 change: 1 addition & 0 deletions app/assets/stylesheets/vendors/vlitejs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "vlitejs/dist/vlite.css";
5 changes: 5 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Entry point for the build script in your package.json
import '@hotwired/turbo-rails'
import './controllers'
import './vendors/appsignal'
import './vendors/turn'
File renamed without changes.
13 changes: 0 additions & 13 deletions app/javascript/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import { Application } from '@hotwired/stimulus'
import { appsignal } from '~/support/appsignal'

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
window.Stimulus = application

// Error handling
const defaultErrorHandler = application.handleError.bind(application)

// create a ne composed error handler with Appsignal
const appsignalErrorHandler = (error, message, detail = {}) => {
defaultErrorHandler(error, message, detail)
appsignal.sendError(error, (span) => { span.setTags({ message }) })
}

// overwrite the default handler with our new composed handler
application.handleError = appsignalErrorHandler

export { application }
20 changes: 16 additions & 4 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { application } from './application'
import { registerControllers } from 'stimulus-vite-helpers'
// This file is auto-generated by ./bin/rails stimulus:manifest:update
// Run that command whenever you add a new controller or create them with
// ./bin/rails generate stimulus controllerName

const controllers = import.meta.globEager('./**/*_controller.js')
registerControllers(application, controllers)
import { application } from "./application"

import AutoSubmitController from "./auto_submit_controller"
application.register("auto-submit", AutoSubmitController)

import PageTransitionMissingController from "./page_transition_missing_controller"
application.register("page-transition-missing", PageTransitionMissingController)

import TransitionController from "./transition_controller"
application.register("transition", TransitionController)

import VideoPlayerController from "./video_player_controller"
application.register("video-player", VideoPlayerController)
1 change: 0 additions & 1 deletion app/javascript/controllers/video_player_controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Controller } from '@hotwired/stimulus'
import 'vlitejs/dist/vlite.css'
import Vlitejs from 'vlitejs'
import VlitejsYoutube from 'vlitejs/dist/providers/youtube'

Expand Down
3 changes: 0 additions & 3 deletions app/javascript/entrypoints/application.css

This file was deleted.

29 changes: 0 additions & 29 deletions app/javascript/entrypoints/application.js

This file was deleted.

5 changes: 0 additions & 5 deletions app/javascript/support/appsignal.js

This file was deleted.

17 changes: 17 additions & 0 deletions app/javascript/vendors/appsignal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Appsignal from '@appsignal/javascript'
import { application } from '../controllers/application'

const key = process.env.NODE_ENV === 'production' ? '4425c854-a76a-4131-992e-171f7bf653ba' : '10b1f5e6-62a2-4bd8-9431-7698de53c68a'

export const appsignal = new Appsignal({ key })

const defaultErrorHandler = application.handleError.bind(application)

// create a ne composed error handler with Appsignal
const appsignalErrorHandler = (error, message, detail = {}) => {
defaultErrorHandler(error, message, detail)
appsignal.sendError(error, (span) => { span.setTags({ message }) })
}

// overwrite the default handler with our new composed handler
application.handleError = appsignalErrorHandler
13 changes: 13 additions & 0 deletions app/javascript/vendors/turn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Turn from '@domchristie/turn'

Turn.start()

document.addEventListener('turbo:before-frame-render', (event) => {
if (document.startViewTransition) {
event.preventDefault()

document.startViewTransition(() => {
event.detail.resume()
})
}
})
2 changes: 1 addition & 1 deletion app/views/analytics/dashboards/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% content_for :head do %>
<%= vite_javascript_tag "chartkick" %>
<%= javascript_include_tag "chartkick", "data-turbo-track": "reload", defer: true %>
<% end %>

<div class="container flex flex-col w-full gap-4 my-8">
Expand Down
5 changes: 2 additions & 3 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<%= display_meta_tags site: "Ruby Video" %>
<%= vite_client_tag %>
<%= vite_javascript_tag "application" %>
<%= vite_stylesheet_tag "application.css" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
<%= yield :head %>
</head>

Expand Down
27 changes: 0 additions & 27 deletions bin/vite

This file was deleted.

Loading

0 comments on commit 4803575

Please sign in to comment.