A project template and a generator to:
- Develop Elm apps with Parcel, Netlify, Tailwind CSS and Cypress
- Learn how these delightful web technologies work together π
- Get started with Elm css, navigation, routes, remote data and JSON decoder
The generated Elm app started with Parcel
behind Netlify Dev and tested with Cypress:
- Demo: elm-batteries.netlify.com/demo
- Documentation: concat.dev/elm
- News and support:
- Mailing list
- Slack (ping @CedricSoulas)
- Elm app with css, navigation, routes, remote data and JSON decoder
- Local web server and serverless functions
- Hot code and style reloading, keeping app state
- Front-end testing
- Optimized and minified production build
- Live, preview and production deployments
- Setup
- Local development
- Develop (Elm + Parcel)
- Develop with serverless functions (Elm + Parcel + Netlify Dev)
- Run a live session
- Testing
- Production build and deployment
- Designing
- See also
Click the Github green button Use this template to generate a new public or private project from elm-batteries.
Install the dependencies:
npm install
π‘ In the following documentation, if you use yarn, run yarn <command-name>
(instead of npm run <command-name>
). Alternatively, you can define short aliases in your terminal to run these commands.
Read Elm + Parcel to use this project template without Netlify Dev and serverless functions.
To run serverless functions along your Elm app, run:
npm run dev
β development build with Parcel
β web server with Parcel behind Netlify Dev
β serverless functions on your local machine
β hot code swapping with elm-hot
- Web page: http://localhost:8888
- Serverless function example:
- http://localhost:8888/.netlify/functions/version
- source:
functions/version/version.js
To share your development session with a coworker, run:
npm run dev:live
β development build with Parcel
β live session with Netlify Dev
These tests are in cypress/integration/*
. Start your Elm app then launch the Cypress runner app:
npm run cypress:open
If you open one test from the list of spec files then you should see your application loaded:
Alternatively, to run Cypress tests from the CLI without the GUI:
npm run cypress
The Elm app uses data-*
attributes to provide context to the selectors and insulate them from CSS or JS changes. Learn more Β»
To learn more about Cypress and play with it, install and start it in a fresh new project folder: it will initialize a cypress
folder with several examples.
Install elm-test.
These tests are in tests/*
. To start the runner in watch mode:
npm run test:watch
Alternatively, run it just once:
npm run test
npm run deploy
β production build with Parcel
β compilation with the Elmoptimize
flag
β minification withterser
β deployment to a Netlify Live Draft URL
π‘ If you are using Netlify for the first time, run netlify login
to authenticate (learn more about Netlify CLI).
π‘ The JS code from Elm is minified with special flags that work for Elm apps because they have no side-effects (otherwise it would be unreliable to use such flags).
If this preview looks good, deploy to production.
npm run deploy:prod
β deployment to production with Netlify
deploy
commands are great when rapidly iterating. Consider also setting up continuous deployment with Netlify Β».
Tailwind CSS, an utility-first CSS framework, is included along with:
postcss
(readpostcss.config.js
),autoprefixer
to add vendor prefixes,purgecss
to remove unused selectors,- and
cssnano
to compress the css (by default with Parcel).
purgecss
and cssnano
are used on production mode to minify the css. They are ignored on development mode.
index.html
has meta tags included, like Twitter Card tags and Open Graph tags. Make sure to update their values and the content preview image (img/content_preview.jpg
).
- All links in an application create a
UrlRequest
(read Browser.application). - A navigation
Key
is needed to create navigation commands that change the URL: it is stored in theModel
. Nav.pushUrl
changes the address bar without starting a page load.
- Documentation: concat.dev/elm/batteries
- Project template: github.com/cedricss/elm-batteries
- News and support:
- Mailing list
- Slack (ping @CedricSoulas)
- Built with elm-batteries:
Authored by CΓ©dric Soulas, released under the MIT License.