npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-elm-batteries

v1.6.0

Published

Create an Elm app, batteries included.

Downloads

5

Readme

MIT license Netlify Status

Elm Batteries Included

A project template and a generator to:

  • Learn how Elm, Parcel, Cypress and Netlify work together 😋
  • Get started with Elm css, navigation, routes, remote data and JSON decoder

Features

  • Local web server and optional serverless functions
  • Hot code and style reloading, keeping app state
  • CSS transformations with postcss (autoprefixer, purgecss...)
  • Front-end testing
  • Optimized and minified production build
  • Preview and production deployments

Table of contents ›

Quick Start

Learn more ›

Links

Overview

Table of contents

Setup

From the CLI

The CLI lets you pick the batteries to include in your app:

npm

npm init elm-batteries ./my-elm-app
cd my-elm-app && npm run dev

or yarn

yarn create elm-batteries ./my-elm-app
cd my-elm-app && yarn dev

From the repository template

Click Use this template to generate a new public or private project from elm-batteries.

Install the dependencies with npm install or yarn install and run npm run dev or yarn dev.


💡 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.

Local development

Develop

To run serverless functions along your Elm app, run

npm run dev

or

yarn dev

Then open localhost:8888

Netlify Dev on top of Parcel and serverless functions

✓ development build with Parcel ✓ web server with Parcel behind Netlify Dev ✓ serverless functions on your local machine ✓ hot code swapping with elm-hot

⚠️ Netlify Dev connects to the 1234 default Parcel port. Make sure this port isn't used by another application.

Develop without Netlify Dev

Read Elm + Parcel to use this project template without Netlify Dev and serverless functions.

Run a live session

To share your development session with a coworker, run:

npm run dev:live

✓ development build with Parcel ✓ live sharing with Netlify Dev

Testing

Run Cypress

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 (for example demo.spec.js) then you should see your application loaded:

Cypress runner app

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.

Run unit and fuzz tests

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

Production build and deployment

Build for production and deploy a preview

npm run deploy

or

yarn deploy

✓ production build with Parcel ✓ compilation with the Elm optimize flag ✓ minification with terser ✓ 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.

Deploy to production

npm run deploy:prod

✓ deployment to production with Netlify

Going further

deploy commands are great when rapidly iterating. Consider also setting up continuous deployment with Netlify ».

Designing

Tailwind CSS, an utility-first CSS framework, is included along with:

purgecss and cssnano are used on production mode to minify the css. They are ignored on development mode.

See also

Meta tags

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).

Elm

Navigation

  • 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 the Model.
  • Nav.pushUrl changes the address bar without starting a page load.

Links and sources

License

Authored by Cédric Soulas, released under the MIT License. Read LICENSE.