Home

Awesome

Elm App Boilerplate

Run Status

Provides an efficient development workflow and a starting point for building Elm applications.

Features

Getting Started

Fork and clone this repo.

npm install
npm start

Open http://localhost:8080/ in a browser.

For an alternative host or port run:

npm start -- --host=0.0.0.0 --port=8081

Testing

Run tests once off:

npm test # Elm and JavaScript tests
npm run test:elm # only Elm tests
npm run test:js # only JavaScript tests

Restart the tests on code change:

npm run tdd # Elm and JavaScript tests
npm run tdd:elm # only Elm tests
npm run tdd:js # only JavaScript tests

Deployment

The deployment is automated using Shippable and is triggered as follows:

  1. Run npm version [major|minor|patch] on the master branch.
  2. Add release notes in GitHub.

On success, the demo app is deployed to elm-app-boilerplate GitHub Pages.

Build Configuration Using Environment Variables

The default environment variables used by the build scripts are defined in the .env file. The defaults are always overridden by the variables defined in the environment. They are useful for abstracting away the differences between the development and production environments. For example, the following command builds the application with a custom BASE_PATH suitable for deployment to GitHub Project Pages.

BASE_PATH=/elm-app-boilerplate npm run build

The environment variables are first available to the webpack.config.babel.js script, so that the build itself can be parameterized. From there, the variables can be passed to JavaScript using DefinePlugin, and from JavaScript to Elm using flags.

Currently the following variables are supported:

Updating Version

This project customizes the standard npm version script to also:

Updating Dependencies

Dependency check and update is handled by ncu. A check runs automatically every time npm version is executed but can also be triggered explicitly.

npm run ncu # checks the dependencies in package.json
npm run ncu -- -a # updates all dependencies in node_modules and package.json

Note: all ncu parameters and flags have to be specified after --.

Elm Commands

The following Elm commands are exposed through npm scripts:

The parameters to those commands must be specified after --, for example: npm run elm-package -- install evancz/elm-effects. See npm run-script.

Directory Structure

General

Elm

JavaScript

HTML

Styling Conventions

Use a BEM-like methodology for styling.

Because the CSS class names are generated from the Elm class names, it is not feasible to follow the BEM class name format. So, here's an alternative:

Here's an example - using the following Elm definitions:

namespace = withNamespace "w"
type CssClass
  = Block
  | Block_modifier
  | Block_modifierWithParam Int
  | Block_Element
  | Block_Element_modifier
  | Block_Element_modifierWithParam Int

we can get CSS class names like these:

.wBlock
.wBlock_modifier
.wBlock_modifierWithParam-1
.wBlock_modifierWithParam-2
.wBlock_modifierWithParam-3
.wBlock_Element
.wBlock_Element_modifier
.wBlock_Element_modifierWithParam-1
.wBlock_Element_modifierWithParam-2
.wBlock_Element_modifierWithParam-3