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

Webpacker migration #3320

Merged
merged 24 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
'parser': 'babel-eslint',
'extends': 'airbnb-base',
'rules': {
'semi': ['error', 'always'],
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ jobs:
RAILS_ENV: test
run: |
bundle exec rails db:create db:schema:load
bundle exec rails test:prepare
murny marked this conversation as resolved.
Show resolved Hide resolved
bundle exec rails test
bundle exec rails test:system
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ vendor/bundle
# Fits
fits.log

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

/app/assets/builds/*
!/app/assets/builds/.keep
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ New entries in this file should aim to provide a meaningful amount of informatio

## [Unreleased]

### Added
- Migrate Webpacker to Esbuild [PR#3320](https://github.com/ualbertalib/jupiter/pull/3320)

### Removed
- Remove fully enabled feature flags that have been enabled for years [PR#3375](https://github.com/ualbertalib/jupiter/pull/3375)

Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ gem 'image_processing' # for ActiveStorage Variants
gem 'puma', '~> 6.4'
gem 'rails', '~> 7.0.8'

# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.4'
# Assets
gem 'cssbundling-rails'
murny marked this conversation as resolved.
Show resolved Hide resolved
gem 'jsbundling-rails'
gem 'sprockets-rails'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
Expand Down
23 changes: 14 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ GEM
bigdecimal
rexml
crass (1.0.6)
cssbundling-rails (1.3.3)
railties (>= 6.0.0)
danger (9.4.3)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
Expand Down Expand Up @@ -285,6 +287,8 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json (2.7.1)
json-schema (4.1.1)
addressable (>= 2.8)
Expand Down Expand Up @@ -385,8 +389,6 @@ GEM
rack (2.2.8.1)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.7)
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
Expand Down Expand Up @@ -512,7 +514,6 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
shoulda-matchers (6.1.0)
activesupport (>= 5.2.0)
sidekiq (7.2.2)
Expand Down Expand Up @@ -555,6 +556,13 @@ GEM
sparql-client (3.3.0)
net-http-persistent (~> 4.0, >= 4.0.2)
rdf (~> 3.3)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
stringio (3.0.8)
strong_migrations (1.7.0)
activerecord (>= 5.2)
Expand Down Expand Up @@ -585,11 +593,6 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (5.4.4)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.8.1)
websocket (1.2.10)
websocket-driver (0.7.6)
Expand Down Expand Up @@ -618,6 +621,7 @@ DEPENDENCIES
capybara (>= 3.26, < 4.0)
clamby
connection_pool
cssbundling-rails
danger (~> 9.4)
datacite-client!
debug
Expand All @@ -633,6 +637,7 @@ DEPENDENCIES
haikunator
image_processing
jbuilder
jsbundling-rails
json-schema (~> 4.1.1)
kaminari
launchy
Expand Down Expand Up @@ -668,13 +673,13 @@ DEPENDENCIES
sidekiq-unique-jobs (~> 8.0)
simple_form
simplecov
sprockets-rails
strong_migrations (~> 1.7.0)
uuidtools
vcr (= 5.0)
voight_kampff (~> 2.0)
web-console (>= 4.1.0)
webmock
webpacker (~> 5.4)
wicked

RUBY VERSION
Expand Down
3 changes: 2 additions & 1 deletion Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
web: env RUBY_DEBUG_OPEN=true bin/rails server
frontend: bin/webpack-dev-server
worker: bundle exec sidekiq
js: yarn build --watch
css: yarn build:css --watch
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bin/dev

This starts up Overmind (or fallback to Foreman) running the Procfile.dev config.

We've configured this to run the Rails server, Sidekiq background worker and webpacker (for CSS bundling and JS bundling) out of the box.
We've configured this to run the Rails server, Sidekiq background worker and CSS/JS bundling out of the box.

Here's a couple of useful Overmind commands:

Expand Down
Empty file added app/assets/builds/.keep
Empty file.
2 changes: 2 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_tree ../builds
File renamed without changes
File renamed without changes
File renamed without changes
27 changes: 27 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Entry point for your Sass build

// Set bootstrap sass variables
@import 'bootstrap-sass-overrides';

// External Library Stylesheets
@import 'bootstrap/scss/bootstrap';

$fa-font-path: ".";

@import "@fortawesome/fontawesome-free/scss/fontawesome.scss";
@import "@fortawesome/fontawesome-free/scss/solid.scss";
@import 'selectize/dist/css/selectize';
@import 'selectize/dist/css/selectize.bootstrap3';
@import 'easy-autocomplete/dist/easy-autocomplete';
@import 'dropzone/dist/dropzone';

// Custom Stylesheets
@import 'jupiter';
@import 'simple_form';
@import 'items';
@import 'image';
@import 'search';
@import 'users';
@import 'welcome';
@import 'skip-content';
@import 'changeset';
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ body {
rgba($white, 0.4),
rgba($white, 0)
),
url('../images/campus-banner.jpg');
url('../assets/campus-banner.jpg');
background-repeat: no-repeat;
background-position: center 10%;
background-size: cover;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[type="search"]::-webkit-search-cancel-button {
// Bootstrap 4 override
murny marked this conversation as resolved.
Show resolved Hide resolved
-webkit-appearance: searchfield-cancel-button;
}

// Filter sidebar for small screens
@include media-breakpoint-between(xs, sm) {
.jupiter-filters {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/helpers/images_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def file_icon(content_type)
def safe_thumbnail_tag(thumbnail, image_tag_options)
image_tag_options[:class] ||= 'j-thumbnail img-thumbnail'
image_tag_options[:onerror] = "this.onerror=null;this.src='#{
asset_pack_url('media/images/era-logo-without-text.png')
image_url('era-logo-without-text.png')
}';"

image_tag(thumbnail, image_tag_options)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/page_layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def thumbnail_path(logo, args = { resize_to_limit: [100, 100], auto_orient: true

# rubocop:disable Rails/HelperInstanceVariable
def page_image_url
default_url = asset_pack_url('media/images/era-logo.png')
default_url = image_url('era-logo.png')
# We only have images on community and item/thesis show pages
image_path = thumbnail_path(@community&.thumbnail_file) || thumbnail_path(@item&.thumbnail_file)

Expand Down
1 change: 1 addition & 0 deletions app/javascript/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './src/admin';
20 changes: 20 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Entry point for the build script in your package.json

import './src/add_jquery';

import Rails from '@rails/ujs';
import Turbolinks from 'turbolinks';
import * as ActiveStorage from '@rails/activestorage';

import 'trix';
import '@rails/actiontext';
import 'bootstrap/dist/js/bootstrap';
import 'selectize/dist/js/standalone/selectize';
import 'easy-autocomplete/dist/jquery.easy-autocomplete';
import 'jquery-multidownload/jquery-multidownload';

import './src/application';

ActiveStorage.start();
Rails.start();
Turbolinks.start();
1 change: 0 additions & 1 deletion app/javascript/packs/admin.js

This file was deleted.

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

This file was deleted.

4 changes: 4 additions & 0 deletions app/javascript/src/add_jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import jquery from 'jquery';

window.jQuery = jquery;
window.$ = jquery;
2 changes: 1 addition & 1 deletion app/javascript/src/admin/ajax_table.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(document).on('turbolinks:load', () => {
document.addEventListener('turbolinks:load', () => {
function renderNewTable() {
murny marked this conversation as resolved.
Show resolved Hide resolved
const $form = $(this).closest('form');
let action = $form.attr('action');
Expand Down
24 changes: 13 additions & 11 deletions app/javascript/src/admin/new_batch_ingest.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,17 @@ function loadAndInitGAPI() {
}

document.addEventListener('turbolinks:load', () => {
loadAndInitGAPI();
$('.js-batch-ingest-spreadsheet').on(
'click',
'.js-btn-delete-file',
deleteSpreadsheet,
);
$('.js-batch-ingest-files-list').on(
'click',
'.js-btn-delete-file',
deleteFileFromFilesList,
);
if (document.querySelector('.js-batch-ingest-spreadsheet')) {
murny marked this conversation as resolved.
Show resolved Hide resolved
loadAndInitGAPI();
$('.js-batch-ingest-spreadsheet').on(
'click',
'.js-btn-delete-file',
deleteSpreadsheet,
);
$('.js-batch-ingest-files-list').on(
'click',
'.js-btn-delete-file',
deleteFileFromFilesList,
);
}
});
27 changes: 0 additions & 27 deletions app/javascript/styles/application.scss

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/application/_feature_image.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
</div>
<% end %>
<% else %>
<%= image_pack_tag('locked-uofa-logo.png', class: 'j-feature-image img-thumbnail', alt: '', size: '350x350') %>
<%= image_tag('locked-uofa-logo.png', class: 'j-feature-image img-thumbnail', alt: '', size: '350x350') %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</li>
</ul>
<%= link_to 'https://www.library.ualberta.ca/', target: :_blank, rel: 'noopener' do %>
<%= image_pack_tag('ualib-logo.png', alt: t('.uofa_library_logo_alt'), size: '262x40') %>
<%= image_tag('ualib-logo.png', alt: t('.uofa_library_logo_alt'), size: '262x40') %>
<% end %>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
</a>
<nav class="container">
<%= link_to root_path, class: 'navbar-brand' do %>
<%= image_pack_tag('era-logo.png',
width: '100',
class: 'align-top d-none d-md-block',
alt: t('.era_logo_alt')) %>
<%= image_pack_tag('era-logo-without-text.png',
width: '100',
class: 'd-inline-block align-top d-md-none',
alt: t('.era_logo_alt')) %>
<%= image_tag('era-logo.png',
width: '100',
class: 'align-top d-none d-md-block',
alt: t('.era_logo_alt')) %>
<%= image_tag('era-logo-without-text.png',
width: '100',
class: 'd-inline-block align-top d-md-none',
alt: t('.era_logo_alt')) %>
<% end %>

<button type="button"
Expand Down
Loading
Loading