Skip to content

Commit 5307b1e

Browse files
committed
set up jsbundling-rails
1 parent 5bbe733 commit 5307b1e

14 files changed

+236
-4
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app/assets/builds

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ yarn-debug.log*
4545

4646
/config/credentials/test.key
4747
docker-compose.yml
48+
49+
/app/assets/builds/*
50+
!/app/assets/builds/.keep

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ gem "rails", "~> 7.0.3"
99
gem "puma", "~> 5.6"
1010
# Use SCSS for stylesheets
1111
gem "sass-rails", ">= 6"
12+
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
13+
gem "jsbundling-rails"
1214
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
1315
gem "jbuilder", "~> 2.11"
1416
# Use Redis adapter to run Action Cable in production

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ GEM
161161
rails-dom-testing (>= 1, < 3)
162162
railties (>= 4.2.0)
163163
thor (>= 0.14, < 2.0)
164+
jsbundling-rails (1.0.3)
165+
railties (>= 6.0.0)
164166
json (2.6.2)
165167
kaminari (1.2.2)
166168
activesupport (>= 4.1.0)
@@ -387,6 +389,7 @@ DEPENDENCIES
387389
guard-rspec (~> 4.7)
388390
hiredis
389391
jbuilder (~> 2.11)
392+
jsbundling-rails
390393
kaminari (~> 1.2)
391394
listen (~> 3.7)
392395
lograge (~> 0.12.0)

Procfile.dev

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rails: bin/rails server -p $PORT
2+
worker: bin/rake jobs:work
3+
js: yarn build --watch

app/assets/builds/.keep

Whitespace-only changes.

app/assets/config/manifest.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//= link_tree ../images
22
//= link_directory ../stylesheets .css
33
//= link_directory ../../../node_modules/bootstrap-icons/icons .svg
4+
//= link_tree ../builds

app/assets/stylesheets/application.css

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
*= require_tree .
1414
*= stub "active_admin"
1515
*= require_self
16+
*= require 'bootstrap/dist/css/bootstrap'
17+
*= require 'bootstrap-icons/font/bootstrap-icons.css'
18+
*= require '@selectize/selectize/dist/css/selectize.bootstrap5.css'
1619
*/

app/javascript/application.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Entry point for the build script in your package.json
2+
3+
import Rails from '@rails/ujs'
4+
import 'bootstrap'
5+
6+
import 'src/preview'
7+
import 'src/bulk_edit'
8+
import 'src/model_edit'
9+
10+
import '@nathanvda/cocoon'
11+
import '@selectize/selectize/dist/js/standalone/selectize.min.js'
12+
13+
Rails.start()

app/views/layouts/application.html.erb

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
<%= csrf_meta_tags %>
77
<%= csp_meta_tag %>
88

9-
<%= javascript_pack_tag 'application' %>
10-
<%= stylesheet_pack_tag 'application', media: 'all' %>
119
<%= stylesheet_link_tag 'application', media: 'all' %>
10+
<%= javascript_include_tag "application", defer: true %>
1211
</head>
1312

1413
<body>

bin/dev

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
if ! foreman version &> /dev/null
4+
then
5+
echo "Installing foreman..."
6+
gem install foreman
7+
fi
8+
9+
foreman start -f Procfile.dev "$@"

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "van-dam",
33
"private": true,
44
"scripts": {
5-
"lint:ts": "ts-standard --fix"
5+
"lint:ts": "ts-standard --fix",
6+
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets"
67
},
78
"dependencies": {
89
"@babel/preset-typescript": "^7.18.6",
@@ -13,8 +14,10 @@
1314
"@selectize/selectize": "^0.13.6",
1415
"bootstrap": "^5.2.0",
1516
"bootstrap-icons": "^1.9.1",
17+
"esbuild": "^0.14.51",
1618
"jquery": "^3.6.0",
1719
"popper.js": "^1.16.1",
20+
"sifter": "^0.5.4",
1821
"three": "^0.143.0",
1922
"typescript": "^4.7.4"
2023
},

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"sourceMap": true,
1414
"strictNullChecks": true,
15-
"target": "es5",
15+
"target": "es6",
1616
"noEmit": true,
1717
"types": [
1818
"./app/javascript/src/globals",

yarn.lock

+192
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)