Compiling Assets with Webpacker
We will learn to add Webpacker in our Compose.
We'll cover the following...
webpack-dev-server
As part of Webpacker, Rails provides the webpack-dev-server binary. This is a small server that runs in the background, automatically compiling our webpack-managed files.
If you were developing locally, this would just be another command you would issue from your terminal. However, the Docker way is to run this as a separate service in its own container.
Modification of Compose
Let’s add a new service for it to our docker-compose.yml file:
Press + to interact
version: '3'services:web:build: .ports:- "3000:3000"volumes:- .:/usr/src/appenv_file:- .env/development/database- .env/development/webenvironment:- WEBPACKER_DEV_SERVER_HOST=webpack-dev-serverwebpack-dev-server:build: .command: ./bin/webpack-dev-serverports:- 3035:3035volumes:- .:/usr/src/appenv_file:- .env/development/web- .env/development/databaseenvironment:- WEBPACKER_DEV_SERVER_HOST=0.0.0.0redis:image: redisdatabase:image: postgresenv_file:- .env/development/databasevolumes:- db_data:/var/lib/postgresql/datavolumes:db_data: