I have a simple JSX file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
With Docker already installed, I fire up a new container:
In this case,
$PWD is the directory where my JSX files live. The
-v flag creates a volume in my container. The
--rm flag will remove the container when I’m finished using it (for convenience).
larryprice/jsx is the image I want to use. This command will watch the current directory and compile the JSX whenever it detects a file change. The generated files will be created next to the JSX files.
What’s in the image, you ask? It’s just the
node:latest image with
react-tools installed which automatically runs the command
jsx --extension jsx --watch src/ src/. It’s fairly simple, but way easier than having to do all this myself.
If I want to use the JSX image with docker-compose alongside the rest of a web application, I might have something like this:
1 2 3 4 5 6 7 8 9 10
It means not having to install Node or npm on your system if you don’t already have it. Being able to compile my SCSS, JSX, and Go code all in once command was a lifesaver, and being able to recreate this environment anywhere meant keeping my computers in-sync was simple. Life, love, and Docker.