Skip to content

Commit

Permalink
Add webpacker gem and install
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Mar 1, 2021
1 parent 9a9b035 commit 62ff092
Show file tree
Hide file tree
Showing 48 changed files with 6,000 additions and 139 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@

# Ignore Rails ENV file
/config/rails_env.rb

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
14 changes: 5 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ gem 'rails', rails

# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.1.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'mini_racer', platforms: :ruby

# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'

# Webpacker makes it easy to use the JavaScript pre-processor webpack
gem 'webpacker', '6.0.0.beta.5'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.11'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand Down
28 changes: 9 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ GEM
exception_notification (4.4.3)
actionmailer (>= 4.0, < 7)
activesupport (>= 4.0, < 7)
execjs (2.7.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.1.0)
Expand Down Expand Up @@ -125,7 +124,6 @@ GEM
activesupport (>= 5.0.0)
json (2.3.1)
jwt (2.2.2)
libv8 (8.4.255.0)
listen (3.4.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand All @@ -143,8 +141,6 @@ GEM
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
mini_racer (0.3.1)
libv8 (~> 8.4.255)
minitest (5.14.4)
msgpack (1.4.2)
multi_json (1.15.0)
Expand Down Expand Up @@ -187,6 +183,8 @@ GEM
rack (2.2.3)
rack-protection (2.1.0)
rack
rack-proxy (0.6.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.3)
Expand Down Expand Up @@ -273,15 +271,10 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.1.0)
railties (>= 5.2.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
scenic (1.5.4)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
semantic_range (2.3.1)
sidekiq (5.2.9)
connection_pool (~> 2.2, >= 2.2.2)
rack (~> 2.0)
Expand Down Expand Up @@ -309,13 +302,8 @@ GEM
thwait (0.2.0)
e2mmap
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
Expand All @@ -325,6 +313,11 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webpacker (6.0.0.beta.5)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -343,7 +336,6 @@ DEPENDENCIES
infreemation
jbuilder (~> 2.11)
listen (>= 3.0.5, < 3.5)
mini_racer
omniauth (~> 2.0.1)
omniauth-google-oauth2
omniauth-rails_csrf_protection
Expand All @@ -356,13 +348,11 @@ DEPENDENCIES
rubocop (~> 1.10.0)
rubocop-performance
rubocop-rails
sass-rails (~> 5.1.0)
scenic
sidekiq (~> 5.2)
sidekiq-scheduler
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webpacker (= 6.0.0.beta.5)
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
web: bundle exec puma -C config/puma.rb -p 3000
wdm: bin/webpack-dev-server
queue: bundle exec sidekiq
3 changes: 0 additions & 3 deletions app/assets/config/manifest.js

This file was deleted.

18 changes: 0 additions & 18 deletions app/assets/javascripts/application-ie9.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/assets/javascripts/application.js

This file was deleted.

13 changes: 0 additions & 13 deletions app/assets/javascripts/cable.js

This file was deleted.

Empty file.
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

19 changes: 19 additions & 0 deletions app/packs/entrypoints/application-ie9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import 'taggle/src/taggle-ie9'
import './application'
27 changes: 27 additions & 0 deletions app/packs/entrypoints/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb


// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

import Rails from '@rails/ujs'
import Turbolinks from 'turbolinks'

Rails.start()
Turbolinks.start()

import '../javascripts/async-delivery-status.js'
import '../javascripts/curated-link-preview.js'
import '../javascripts/keyword-picker.js'
import '../javascripts/print-button.js'
13 changes: 13 additions & 0 deletions app/packs/entrypoints/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@import '../stylesheets/buttons.scss';
@import '../stylesheets/cta-section.scss';
@import '../stylesheets/flashes.scss';
@import '../stylesheets/foi-preview.scss';
@import '../stylesheets/foi-suggestion.scss';
@import '../stylesheets/forms.scss';
@import '../stylesheets/govuk-box-highlight.scss';
@import '../stylesheets/header.scss';
@import '../stylesheets/keyword-picker.scss';
@import '../stylesheets/print-button.scss';
@import '../stylesheets/print.scss';
@import '../stylesheets/subheader.scss';
@import '../stylesheets/typography.scss';
File renamed without changes.
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $ */
import $ from 'jquery'

var checkDeliveryStatus = function () {
var $box = $(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global $ */
import $ from 'jquery'

var updateCuratedLinkPreview = function (inputs, previews) {
previews.$url.attr('href', inputs.$url.val() || '#')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global $, Taggle */
import $ from 'jquery'
import Taggle from 'taggle'

var removeEmptyItems = function (array) {
var cleaned = []
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
display: inline-block;
width: 16px;
height: 16px;
background: transparent url(asset_path('link-external.png')) 0 0 no-repeat;
background-image: url(asset_path('link-external.svg')), none;
background: transparent url('../images/link-external.png') 0 0 no-repeat;
background-image: url('../images/link-external.svg'), none;
margin-left: 0.5em;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<% content_for :head do %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<!--[if lte IE 9]>
<%= javascript_include_tag 'application-ie9', async: true, 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application-ie9', async: true, 'data-turbolinks-track': 'reload' %>
<![endif]-->
<!--[if gt IE 9]><!-->
<%= javascript_include_tag 'application', async: true, 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', async: true, 'data-turbolinks-track': 'reload' %>
<!--<![endif]-->
<% end %>

Expand Down
2 changes: 2 additions & 0 deletions bin/rails-deploy-before-down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ bin/bundle config set path 'vendor/bundle'
bin/bundle config set without 'development test'
bin/bundle install

bin/yarn install

bin/rails assets:precompile
19 changes: 19 additions & 0 deletions bin/webpack
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
ENV['NODE_ENV'] ||= 'development'

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

require 'bundler/setup'

require 'webpacker'
require 'webpacker/webpack_runner'

APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)
end
19 changes: 19 additions & 0 deletions bin/webpack-dev-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
ENV['NODE_ENV'] ||= 'development'

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)

require 'bundler/setup'

require 'webpacker'
require 'webpacker/dev_server_runner'

APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::DevServerRunner.run(ARGV)
end
Loading

0 comments on commit 62ff092

Please sign in to comment.