Create Elm apps with no build configuration.
- Getting Started – How to create a new app.
- User Guide – How to develop apps bootstrapped with Create Elm App.
npm install create-elm-app -g
create-elm-app my-app
cd my-app/
elm-app start
Create a production build with elm-app build
Node >=6 is required for installation.
yarn global add create-elm-app
npm install create-elm-app -g
If you are running Linux OS, you should install it as the superuser:
sudo npm install create-elm-app -g
To create a new app, run:
create-elm-app my-app
cd my-app/
Create a new my-app
folder with files for your future project.
my-app/
├── .gitignore
├── README.md
├── elm-package.json
├── elm-stuff
├── public
│ ├── favicon.ico
│ ├── index.html
│ ├── logo.svg
│ └── manifest.json
├── src
│ ├── Main.elm
│ ├── index.js
│ ├── main.css
│ └── registerServiceWorker.js
└── tests
├── Tests.elm
└── elm-package.json
You are ready to employ the full power of Create Elm App!
Run the app in development mode. Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits. You will see the build errors and lint warnings in the console and the browser window.
Builds the app for production to the build
folder.
It bundles Elm app and optimizes the build for the best performance.
The build is minified, and the filenames include the hashes.
Every generated project will contain a readme with guidelines for future development. The latest version is available here
Developing with elm-platform is fun and easy, but at some point, you will hit a couple of limitations.
- elm-make does not provide an efficient build tool for optimizing your project.
- elm-reactor does not work with apps that rely on ports.
- You can not use Hot Module Replacement.
Create Elm App adds a tool for optimizing production builds and running a development server with your app, which supports HMR.
All of that, combined with all the basic functionality of elm-platform in a single command line tool, which you might use as a dependency or eject
anytime.
Not happy with the default configuration? Use elm-app eject
and customize your process.
That way, you can use Create Elm App as a tool for a boilerplate generation.
Inspired by create-react-app
-
One Dependency: There is just one build dependency. It uses Elm Platform, Webpack, and other amazing projects, but provides a cohesive curated experience on top of them.
-
Zero Configuration: There are no configuration files or command line options. Configuring both development and production builds is handled for you so you can focus on writing code.
-
No Lock-In: You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
The tools used by Create Elm App are subject to change. Currently it is a thin layer on top of many amazing community projects, such as:
- elm-platform
- elm-test
- webpack with webpack-dev-server, html-webpack-plugin and style-loader
- Babel with ES6
- Autoprefixer
- and others.
All of them are transitive dependencies of the provided npm package.
We would love to get you involved! Please check our Contributing Guide to get started!
- elm-webpack-starter
- elm-app-boilerplate
- elm-hot-loader-starter
- elm-starter
- elm-live
- generator-elmlang
You can run together Elm with React and CSS modules.
yarn add react react-dom
yarn add babel-preset-env babel-preset-stage-0 babel-plugin-transform-react-jsx -D
Create .babelrc
file:
{
"presets": ["env", "stage-0"],
"plugins": [
["transform-react-jsx"]
]
}
Create CSS module file styles.module.css
(the filename has to use .module.css suffix)
.highlight {
color: red;
background-color: yellow;
}
Create HiReact.js
file:
import React from 'react';
import styles from './styles.module.css';
export default function HiReact () {
return (
<h1 className={styles.highlight}>Hi React!</h1>
);
}
Add two placeholders into public/index.html
(inside the <body>
tag).
<div id="react-root">Loading React...</div>
<div id="elm-root">Loading Elm</div>
Change starting index.js
to
import React from 'react';
import { render } from 'react-dom';
import HiReact from './HiReact';
import './main.css';
import { Main } from './Main.elm';
import registerServiceWorker from './registerServiceWorker';
render(<HiReact/>, document.getElementById('react-root'));
Main.embed(document.getElementById('elm-root'));
registerServiceWorker();
Start the app
/path/to/this/github/create-elm-app/bin/elm-app-cli.js start