Skip to content

Commit 5fbbd70

Browse files
committed
tools: Auto-rebuild webpack assets with foreman.
1 parent 0f081f6 commit 5fbbd70

File tree

8 files changed

+18
-19
lines changed

8 files changed

+18
-19
lines changed

Dockerfile.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ set -eu
5454
ln -s /node_modules node_modules
5555

5656
bundle exec rake db:migrate
57-
bundle exec rails server -b 0.0.0.0 -p 80 || true
57+
./bin/dev || true
5858

5959
echo "Rails exited, sleeping indefinitely so dev shells don't die."
6060
sleep inf

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ group :development do
117117
gem "rubocop-rails"
118118
gem "rubocop-rspec"
119119
gem "rubocop-rspec_rails"
120+
121+
# For ./bin/dev
122+
gem "foreman"
120123
end
121124

122125
# Development/Test shared dependencies

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ GEM
165165
ffi (1.17.2-x86_64-linux-musl)
166166
font-awesome-sass (5.15.1)
167167
sassc (>= 1.11)
168+
foreman (0.90.0)
169+
thor (~> 1.4)
168170
friendly_id (5.6.0)
169171
activerecord (>= 4.0.0)
170172
globalid (1.3.0)
@@ -513,6 +515,7 @@ DEPENDENCIES
513515
factory_bot_rails
514516
faker
515517
font-awesome-sass (~> 5.15)
518+
foreman
516519
friendly_id
517520
httparty
518521
identicon (= 0.0.5)

Procfile.dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
web: env RUBY_DEBUG_OPEN=true bin/rails server
2-
js: yarn build --watch
1+
rails: env RUBY_DEBUG_OPEN=true ./bin/rails server --binding=0.0.0.0 --port=3000
2+
webpack: npm run watch

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ See the `Makefile` for all commands.
3838
> Note: the tool versions in nix are not entirely correct.
3939

4040
1. Install gems: `bundle install`
41-
2. Migrate the db using `bundle exec rails db:migrate`
42-
3. Seed the db using `bundle exec rails db:seed`
43-
4. Run `rake webpacker:compile`
44-
5. Start Tap by running `bundle exec rails s`
41+
1. Install npm packages: `npm i`
42+
2. Initialize and migrate the db: `bundle exec rails db:migrate`
43+
3. Seed the db: `bundle exec rails db:seed`
44+
5. Start Tap: `./bin/dev`
4545

4646
## Deploy to production
4747

bin/dev

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
#!/usr/bin/env sh
22

3-
if gem list --no-installed --exact --silent foreman; then
4-
echo "Installing foreman..."
5-
gem install foreman
6-
fi
7-
8-
# Default to port 3000 if not specified
9-
export PORT="${PORT:-3000}"
10-
113
exec foreman start -f Procfile.dev --env /dev/null "$@"

compose.development.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
dockerfile: Dockerfile.development
77
target: development
88
ports:
9-
- "127.0.0.1:3000:80"
9+
- "127.0.0.1:3000:3000"
1010
volumes:
1111
- "./:/tap"
1212
# - "${HOME}/.ssh:/root/.ssh:ro"

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "app",
33
"private": true,
4-
"scripts": {
5-
"build": "webpack --config webpack.config.js"
6-
},
74
"dependencies": {
85
"webpack": "^5.104.1",
96
"webpack-cli": "^6.0.1"
7+
},
8+
"scripts": {
9+
"build": "webpack --config webpack.config.js",
10+
"watch": "webpack --config webpack.config.js --watch"
1011
}
1112
}

0 commit comments

Comments
 (0)