A miniature version of Virkr (www.virkr.dk) build for demonstration purposes
- React
- Simple state management
- Twitter Bootstrap (Bootswatch Superhero theme)
- Webpack 4
- Babel
- Yarn
- ES2017 async/await
- Deploy to nginx using Docker and multistage build
In order to be able to build and run Mini Virkr, you will need to have Node.js and NPM/Yarn installed.
You get npm when you install Node. Instructions for installing Node can be found online:
-
Mac
Easiest way is to use HomeBrew (https://brew.sh/). Follow these instructions. If you already have HomeBrew installed, simply run
brew install node
-
Windows
Instructions are here
-
Linux
Instructions for Debian/Ubuntu/Mint etc. are here
After installation you should be able to run npm -v
successfully.
Yarn is a package manager like npm, but faster and with more features. Ironically, you can use npm to install yarn.
After you have verified that npm is correctly installed, run this:
npm install --global yarn
Or, if you re mac'ed, do it with HomeBrew:
brew install yarn
Here are some other tools you may find useful.
If you want to create your own React application, we recommend create-react-app:
yarn global add create-react-app
Sublime Text, Atom and Visual Studio Code are all great editors for developing Javascript applications. So is Intellij IDEA - Use what you prefer.
The developer tools in the Chrome editor are superb. You can enhance it by adding React Developer Tools.
Here are instructions for running Mini Virkr locally. All commands are executed from the command line in the folder where you cloned or downloaded the source code.
yarn
This will fetch all project dependencies and install them in the project node_modules
folder
yarn start
This starts a small webserver on http://localhost:9000. It automatically refreshes the browser when you make changes in the source code.
yarn run devbuild
This will build a development version and place the result in the dist
folder.
yarn build
This will build a production version and place the result in the dist
folder. The production version is smaller that the development version, because the code has been compressed and uglified.
The contents of the dist
folder are meant to be served by a webserver, such as nginx or apache. You can quickly spin up a Docker container with nginx and the application, as explained in the next section.
Select an image name you fancy (nine/minivirkr
is used in this example)
docker build . -t nine/minivirkr
docker run -p80:80 nine/minivirkr
Then go to http://localhost