{"id":22696872,"url":"https://github.com/maxbeizer/todo-elm","last_synced_at":"2025-03-29T18:22:15.432Z","repository":{"id":143122454,"uuid":"141901931","full_name":"maxbeizer/todo-elm","owner":"maxbeizer","description":"working on learning Elm","archived":false,"fork":false,"pushed_at":"2018-07-24T03:02:49.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T21:09:20.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxbeizer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-22T14:17:09.000Z","updated_at":"2018-07-24T03:02:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed8956ce-0a7c-4969-86f0-d71c98648b18","html_url":"https://github.com/maxbeizer/todo-elm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeizer%2Ftodo-elm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeizer%2Ftodo-elm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeizer%2Ftodo-elm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxbeizer%2Ftodo-elm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxbeizer","download_url":"https://codeload.github.com/maxbeizer/todo-elm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246224337,"owners_count":20743360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-10T05:11:28.447Z","updated_at":"2025-03-29T18:22:15.414Z","avatar_url":"https://github.com/maxbeizer.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project is bootstrapped with [Create Elm App](https://github.com/halfzebra/create-elm-app).\n\nBelow you will find some information on how to perform basic tasks.\nYou can find the most recent version of this guide [here](https://github.com/halfzebra/create-elm-app/blob/master/template/README.md).\n\n## Table of Contents\n- [Sending feedback](#sending-feedback)\n- [Folder structure](#folder-structure)\n- [Installing Elm packages](#installing-elm-packages)\n- [Installing JavaScript packages](#installing-javascript-packages)\n- [Available scripts](#available-scripts)\n  - [elm-app build](#elm-app-build)\n  - [elm-app start](#elm-app-start)\n  - [elm-app install](#elm-app-install)\n  - [elm-app test](#elm-app-test)\n  - [elm-app eject](#elm-app-eject)\n  - [elm-app \u003celm-platform-command\u003e](#elm-app-elm-platform-command)\n    - [package](#package)\n    - [repl](#repl)\n    - [make](#make)\n    - [reactor](#reactor)\n- [Turning on/off Elm Debugger](#turning-onoff-elm-debugger)\n- [Dead code elimination](#dead-code-elimination)\n- [Changing the Page `\u003ctitle\u003e`](#changing-the-page-title)\n- [JavaScript Interop](#javascript-interop)\n- [Adding a Stylesheet](#adding-a-stylesheet)\n- [Post-Processing CSS](#post-processing-css)\n- [Using elm-css](#using-elm-css)\n- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc)\n- [Adding Images and Fonts](#adding-images-and-fonts)\n- [Using the `public` Folder](#using-the-public-folder)\n  - [Changing the HTML](#changing-the-html)\n  - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)\n  - [When to Use the `public` Folder](#when-to-use-the-public-folder)\n- [Using custom environment variables](#using-custom-environment-variables)\n- [Setting up API Proxy](#setting-up-api-proxy)\n- [Running tests](#running-tests)\n  - [Dependencies in Tests](#dependencies-in-tests)\n  - [Continuous Integration](#continuous-integration)\n- [Making a Progressive Web App](#making-a-progressive-web-app)\n  - [Opting Out of Caching](#opting-out-of-caching)\n  - [Offline-First Considerations](#offline-first-considerations)\n  - [Progressive Web App Metadata](#progressive-web-app-metadata)\n- [Deployment](#deployment)\n  - [Building for Relative Paths](#building-for-relative-paths)\n  - [Static Server](#static-server)\n  - [GitHub Pages](#github-pages)\n- [IDE setup for Hot Module Replacement](#ide-setup-for-hot-module-replacement)\n\n## Sending feedback\n\nYou are very welcome with any [feedback](https://github.com/halfzebra/create-elm-app/issues)\n\n## Installing Elm packages\n\n```sh\nelm-app install \u003cpackage-name\u003e\n```\n\nOther `elm-package` commands are also [available.](#package)\n\n## Installing JavaScript packages\n\nTo use JavaScript packages from npm, you'll need to add a `package.json`, install the dependencies, and you're ready to go.\n\n```sh\nnpm init -y # Add package.json\nnpm install --save-dev pouchdb-browser # Install library from npm\n```\n\n```js\n// Use in your JS code\nimport PouchDB from 'pouchdb-browser';\nconst db = new PouchDB('mydb');\n```\n\n## Folder structure\n\n```\nmy-app/\n├── .gitignore\n├── README.md\n├── elm-package.json\n├── elm-stuff\n├── public\n│   ├── favicon.ico\n│   ├── index.html\n│   ├── logo.svg\n│   └── manifest.json\n├── src\n│   ├── Main.elm\n│   ├── index.js\n│   ├── main.css\n│   └── registerServiceWorker.js\n└── tests\n    ├── Tests.elm\n    └── elm-package.json\n```\n\nFor the project to build, these files must exist with exact filenames:\n\n- `public/index.html` is the page template;\n- `public/favicon.ico` is the icon you see in the browser tab;\n- `src/index.js` is the JavaScript entry point.\n\nYou can delete or rename the other files.\n\nYou may create subdirectories inside src.\n\n## Available scripts\nIn the project directory you can run:\n### `elm-app build`\nBuilds the app for production to the `build` folder.\n\nThe build is minified, and the filenames include the hashes.\nYour app is ready to be deployed!\n\n### `elm-app start`\nRuns the app in the development mode.\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.\nYou will also see any lint errors in the console.\n\n### `elm-app install`\n\nAn alias for [`elm-app package install`](#package)\n\n### `elm-app test`\nRun tests with [node-test-runner](https://github.com/rtfeldman/node-test-runner/tree/master)\n\nYou can make test runner watch project files by running:\n```sh\nelm-app test --watch\n```\n\n### `elm-app eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time.\n\nInstead, it will copy all the configuration files and the transitive dependencies (Webpack, Elm Platform, etc.) right into your project, so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point, you’re on your own.\n\nYou don’t have to use 'eject' The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However, we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n### `elm-app \u003celm-platform-command\u003e`\n\nCreate Elm App does not rely on the global installation of Elm Platform, but you still can use its local Elm Platform to access default command line tools:\n\n#### `package`\n\nAlias for [elm-package](http://guide.elm-lang.org/get_started.html#elm-package)\n\nUse it for installing Elm packages from [package.elm-lang.org](http://package.elm-lang.org/)\n\n#### `repl`\n\nAlias for [elm-repl](http://guide.elm-lang.org/get_started.html#elm-repl)\n\n#### `make`\n\nAlias for  [elm-make](http://guide.elm-lang.org/get_started.html#elm-make)\n\n#### `reactor`\n\nAlias for  [elm-reactor](http://guide.elm-lang.org/get_started.html#elm-reactor)\n\n\n## Turning on/off Elm Debugger\n\nBy default, in production (`elm-app build`) the Debugger is turned off and in development mode (`elm-app start`) it's turned on.\n\nTo turn on/off Elm Debugger explicitly, set `ELM_DEBUGGER` environment variable to `true` or `false` respectively.\n\n## Dead code elimination\n\nCreate Elm App comes with an opinionated setup for dead code elimination which is disabled by default, because it may break your code.\n\nYou can enable it by setting `DEAD_CODE_ELIMINATION` environment variable to `true`\n\n## Changing the base path of the assets in the HTML\n\nBy default, assets will be linked from the HTML to the root url. For example `/css/style.css`.\n\nIf you deploy to a path that is not the root, you can change the `PUBLIC_URL` environment variable to properly reference your assets in the compiled assets. For example: `PUBLIC_URL=./ elm-app build`.\n\n## Changing the Page `\u003ctitle\u003e`\n\nYou can find the source HTML file in the `public` folder of the generated project. You may edit the `\u003ctitle\u003e` tag in it to change the title from “Elm App” to anything else.\n\nNote that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML.\n\nIf you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API and JavaScript interoperation. The next section of this tutorial will explain it in more detail.\n\n## JavaScript Interop\n\nYou can send and receive values from JavaScript using the concept of [ports.](https://guide.elm-lang.org/interop/javascript.html#ports).\n\nIn the following example we will use JavaScript to change the page title dynamically. To make it work with files created by `create-elm-app` you need to modify\n`src/index.js` file to look like this:\n\n```js\nimport './main.css';\nimport { Main } from './Main.elm';\nimport registerServiceWorker from './registerServiceWorker';\n\nvar app = Main.embed(document.getElementById('root'));\n\nregisterServiceWorker();\n\n// ports related code\napp.ports.windowTitle.subscribe(function(newTitle){\n    window.document.title = newTitle;\n});\n```\nPlease note the `windowTitle` port in the above example, more about it later.\n\nFirst let's allow the Main module to use ports and in `Main.elm` file please append `port` to the module declaration:\n\n```elm\nport module Main exposing (..)\n```\nDo you remember `windowTitle` in JavaScript? Let's declare the port:\n```elm\nport windowTitle : String -\u003e Cmd msg\n```\nand use it to call JavaScript in you update function.\n```elm\nupdate : Msg -\u003e Model -\u003e ( Model, Cmd Msg )\nupdate msg model =\n    case msg of\n        Inc -\u003e\n            ( { model | counter = model.counter + 1}\n            , windowTitle (\"Elm-count up \" ++ (toString (model.counter + 1)))\n            )\n        Dec -\u003e\n            ( { model | counter = model.counter - 1}\n            , windowTitle (\"Elm-count down \" ++ (toString (model.counter - 1))))\n        NoOp -\u003e\n            ( model, Cmd.none )\n```\nPlease note that for Inc and Dec operations `Cmd.none` was replaced with `windowTitle` port call that is executed on the JavaScript side..\n\n## Adding a Stylesheet\n\nThis project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:\n\n### `main.css`\n\n```css\nbody {\n  padding: 20px;\n}\n```\n\n### `index.js`\n\n```js\nimport './main.css'; // Tell Webpack to pick-up the styles from main.css\n```\n\n## Post-Processing CSS\n\nThis project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it.\n\nFor example, this:\n\n```css\n.container {\n  display: flex;\n}\n```\n\nbecomes this:\n\n```css\n.container {\n  display: -webkit-box;\n  display: -ms-flexbox;\n  display: flex;\n}\n```\n\nIn development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output.\n\nYou can put all your CSS right into `src/main.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.\n\n## Using elm-css\n\n### Step 1: Install [elm-css](https://github.com/rtfeldman/elm-css) npm package\n\n```sh\nnpm install elm-css -g\n```\n\n### Step 2: Install Elm dependencies\n\n```sh\nelm-app install rtfeldman/elm-css\nelm-app install rtfeldman/elm-css-helpers\n```\n\n### Step 3: Create the stylesheet file\n\nCreate an Elm file at `src/Stylesheets.elm` (The name of this file cannot be changed).\n\n```elm\nport module Stylesheets exposing (main, CssClasses(..), CssIds(..), helpers)\n\nimport Css exposing (..)\nimport Css.Elements exposing (body, li)\nimport Css.Namespace exposing (namespace)\nimport Css.File exposing (..)\nimport Html.CssHelpers exposing (withNamespace)\n\n\nport files : CssFileStructure -\u003e Cmd msg\n\n\ncssFiles : CssFileStructure\ncssFiles =\n    toFileStructure [ ( \"src/style.css\", Css.File.compile [ css ] ) ]\n\n\nmain : CssCompilerProgram\nmain =\n    Css.File.compiler files cssFiles\n\n\ntype CssClasses\n    = NavBar\n\n\ntype CssIds\n    = Page\n\n\nappNamespace =\n    \"App\"\n\n\nhelpers =\n    withNamespace appNamespace\n\n\ncss =\n    (stylesheet \u003c\u003c namespace appNamespace)\n    [ body\n        [ overflowX auto\n        , minWidth (px 1280)\n        ]\n    , id Page\n        [ backgroundColor (rgb 200 128 64)\n        , color (hex \"CCFFFF\")\n        , width (pct 100)\n        , height (pct 100)\n        , boxSizing borderBox\n        , padding (px 8)\n        , margin zero\n        ]\n    , class NavBar\n        [ margin zero\n        , padding zero\n        , children\n            [ li\n                [ (display inlineBlock) |\u003e important\n                , color primaryAccentColor\n                ]\n            ]\n        ]\n    ]\n\n\nprimaryAccentColor =\n    hex \"ccffaa\"\n```\n\n### Step 4: Compiling the stylesheet\n\nTo compile the CSS file, just run\n\n```sh\nelm-css src/Stylesheets.elm\n```\n\nThis will generate a file called `style.css`\n\n### Step 5: Import the compiled CSS file\n\nAdd the following line to your `src/index.js`:\n\n```js\nimport './style.css';\n```\n\n### Step 6: Using the stylesheet in your Elm code\n\n```elm\nimport Stylesheets exposing (helpers, CssIds(..), CssClasses(..))\n\n\nview model =\n    div [ helpers.id Page ]\n        [ div [ helpers.class [ NavBar ] ]\n            [ text \"Your Elm App is working!\" ]\n        ]\n```\n\nPlease note that `Stylesheets.elm` exposes `helpers` record, which contains functions for creating id and class attributes.\n\nYou can also destructure `helpers` to make your view more readable:\n\n```elm\n{ id, class } =\n    helpers\n```\n\n## Adding a CSS Preprocessor (Sass, Less etc.)\n\nIf you find CSS preprocessors valuable you can integrate one. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative.\n\nFirst we need to create a `package.json` file, since create-elm-app is not shipping one at the moment. Walk through the normal `npm init` process.\n```\nnpm init\n```\n\nSecond, let’s install the command-line interface for Sass:\n\n```sh\nnpm install --save node-sass-chokidar\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add node-sass-chokidar\n```\n\nThen in `package.json`, add the following lines to `scripts`:\n\n```diff\n   \"scripts\": {\n+    \"build-css\": \"node-sass-chokidar src/ -o src/\",\n+    \"watch-css\": \"npm run build-css \u0026\u0026 node-sass-chokidar src/ -o src/ --watch --recursive\",\n    ...\n   }\n```\n\n\u003eNote: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation.\n\nNow you can rename `src/main.css` to `src/main.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/main.css`. Since `src/index.js` still imports `src/main.css`, the styles become a part of your application. You can now edit `src/main.scss`, and `src/main.css` will be regenerated.\n\nTo share variables between Sass files, you can use Sass imports. For example, `src/main.scss` and other component style files could include `@import \"./shared.scss\";` with variable definitions.\n\nTo enable importing files without using relative paths, you can add the  `--include-path` option to the command in `package.json`.\n\n```\n\"build-css\": \"node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/\",\n\"watch-css\": \"npm run build-css \u0026\u0026 node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive\",\n```\n\nThis will allow you to do imports like\n\n```scss\n@import 'styles/_colors.scss'; // assuming a styles directory under src/\n@import 'nprogress/nprogress'; // importing a css file from the nprogress node module\n```\n\nAt this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control.\n\n\n**Why `node-sass-chokidar`?**\n\n`node-sass` has been reported as having the following issues:\n\n- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker.\n\n- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939)\n\n- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891)\n\n `node-sass-chokidar` is used here as it addresses these issues.\n\n## Adding Images and Fonts\n\nWith Webpack, using static assets like images and fonts works similarly to CSS.\n\nBy requiring an image in JavaScript code, you tell Webpack to add a file to the build of your application. The variable will contain a unique path to the said file.\n\nHere is an example:\n\n```js\nimport logoPath from './logo.svg'; // Tell Webpack this JS file uses this image\nimport { Main } from './Main.elm';\n\nMain.embed(\n    document.getElementById('root'),\n    logoPath // Pass image path as a flag for Html.programWithFlags\n  );\n```\n\nLater on, you can use the image path in your view for displaying it in the DOM.\n\n```elm\nview : Model -\u003e Html Msg\nview model =\n    div []\n        [ img [ src model.logo ] []\n        , div [] [ text model.message ]\n        ]\n```\n\n## Using the `public` Folder\n\n### Changing the HTML\n\nThe `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title).\nThe `\u003cscript\u003e` tag with the compiled code will be added to it automatically during the build process.\n\n### Adding Assets Outside of the Module System\n\nYou can also add other assets to the `public` folder.\n\nNote that we normally encourage you to `import` assets in JavaScript files instead.\nFor example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files).\nThis mechanism provides a few benefits:\n\n* Scripts and stylesheets get minified and bundled together to avoid extra network requests.\n* Missing files cause compilation errors instead of 404 errors for your users.\n* Result filenames include content hashes, so you don’t need to worry about browsers caching their old versions.\n\nHowever, there is a **escape hatch** that you can use to add an asset outside of the module system.\n\nIf you put a file into the `public` folder, it will **not** be processed by Webpack. Instead, it will be copied into the build folder untouched.   To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`.\n\nInside `index.html`, you can use it like this:\n\n```html\n\u003clink rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\"\u003e\n```\n\nOnly files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build.\n\nWhen you run `elm-app build`, Create Elm App will substitute `%PUBLIC_URL%` with a correct absolute path, so your project works even if you use client-side routing or host it at a non-root URL.\n\nIn Elm code, you can use `%PUBLIC_URL%` for similar purposes:\n\n```elm\n// Note: this is an escape hatch and should be used sparingly!\n// Normally we recommend using `import`  and `Html.programWithFlags` for getting\n// asset URLs as described in “Adding Images and Fonts” above this section.\nimg [ src \"%PUBLIC_URL%/logo.svg\" ] []\n```\n\nIn JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes:\n\n```js\nconst logo = `\u003cimg src=${process.env.PUBLIC_URL + '/img/logo.svg'} /\u003e`;\n```\n\nKeep in mind the downsides of this approach:\n\n* None of the files in `public` folder get post-processed or minified.\n* Missing files will not be called at compilation time, and will cause 404 errors for your users.\n* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change.\n\n### When to Use the `public` Folder\n\nNormally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript.\nThe `public` folder is used as a workaround for some less common cases:\n\n* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest).\n* You have thousands of images and need to dynamically reference their paths.\n* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code.\n* Some library may be incompatible with Webpack and you have no other option but to include it as a `\u003cscript\u003e` tag.\n\nNote that if you add a `\u003cscript\u003e` that declares global variables, you also need to read the next section on using them.\n\n\n## Using custom environment variables\n\nIn your JavaScript code you have access to variables declared in your\nenvironment, like an API key set in an `.env`-file or via your shell. They are\navailable on the `process.env`-object and will be injected during build time.\n\nBesides the `NODE_ENV` variable you can access all variables prefixed with\n`ELM_APP_`:\n\n```bash\n# .env\nELM_APP_API_KEY=\"secret-key\"\n```\n\nAlternatively, you can set them on your shell before calling the start- or\nbuild-script, e.g.:\n\n```bash\nELM_APP_API_KEY=\"secret-key\" elm-app start\n```\n\nBoth ways can be mixed, but variables set on your shell prior to calling one of\nthe scripts will take precedence over those declared in an `.env`-file.\n\nPassing the variables to your Elm-code can be done via `flags`:\n\n```javascript\n// index.js\nimport { Main } from './Main.elm';\n\nMain.fullscreen({\n  environment: process.env.NODE_ENV,\n  apiKey: process.env.ELM_APP_API_KEY,\n});\n```\n\n```elm\n-- Main.elm\ntype alias Flags = { apiKey : String, environment : String }\n\ninit : Flags -\u003e ( Model, Cmd Msg )\ninit flags =\n  ...\n\nmain =\n  programWithFlags { init = init, ... }\n```\n\nBe aware that you cannot override `NODE_ENV` manually. See\n[this list from the `dotenv`-library](https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use)\nfor a list of files you can use to declare environment variables.\n\n\n## Setting up API Proxy\nTo forward the API ( REST ) calls to backend server, add a proxy to the `elm-package.json` in the top level json object.\n\n```json\n{\n    ...\n    \"proxy\" : \"http://localhost:1313\",\n    ...\n}\n```\n\nMake sure the XHR requests set the `Content-type: application/json` and `Accept: application/json`.\nThe development server has heuristics, to handle its own flow, which may interfere with proxying of\nother html and javascript content types.\n\n```sh\n curl -X GET -H \"Content-type: application/json\" -H \"Accept: application/json\"  http://localhost:3000/api/list\n```\n\n## Running Tests\n\nCreate Elm App uses [elm-test](https://github.com/rtfeldman/node-test-runner) as its test runner.\n\n### Dependencies in Tests\n\nTo use packages in tests, you also need to install them in `tests` directory.\n\n```bash\nelm-app test --add-dependencies elm-package.json\n```\n\n### Continuous Integration\n\n#### Travis CI\n\n1. Following the [Travis Getting started](https://docs.travis-ci.com/user/getting-started/) guide for syncing your GitHub repository with Travis.  You may need to initialize some settings manually in your [profile](https://travis-ci.org/profile) page.\n1. Add a `.travis.yml` file to your git repository.\n\n```yaml\nlanguage: node_js\n\nsudo: required\n\nnode_js:\n  - '7'\n\ninstall:\n  - npm i create-elm-app -g\n\nscript: elm-app test\n```\n\n1. Trigger your first build with a git push.\n1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed.\n\n## Making a Progressive Web App\n\nBy default, the production build is a fully functional, offline-first\n[Progressive Web App](https://developers.google.com/web/progressive-web-apps/).\n\nProgressive Web Apps are faster and more reliable than traditional web pages, and provide an engaging mobile experience:\n\n * All static site assets are cached so that your page loads fast on subsequent visits, regardless of network connectivity (such as 2G or 3G). Updates are downloaded in the background.\n * Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the Subway.\n * On mobile devices, your app can be added directly to the user's home screen, app icon and all. You can also re-engage users using web **push notifications**. This eliminates the need for the app store.\n\nThe [`sw-precache-webpack-plugin`](https://github.com/goldhand/sw-precache-webpack-plugin)\nis integrated into production configuration,\nand it will take care of generating a service worker file that will automatically\nprecache all of your local assets and keep them up to date as you deploy updates.\nThe service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network)\nfor handling all requests for local assets, including the initial HTML, ensuring\nthat your web app is reliably fast, even on a slow or unreliable network.\n\n### Opting Out of Caching\n\nIf you would prefer not to enable service workers prior to your initial\nproduction deployment, then remove the call to `serviceWorkerRegistration.register()`\nfrom [`src/index.js`](src/index.js).\n\nIf you had previously enabled service workers in your production deployment and\nhave decided that you would like to disable them for all your existing users,\nyou can swap out the call to `serviceWorkerRegistration.register()` in\n[`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`.\nAfter the user visits a page that has `serviceWorkerRegistration.unregister()`,\nthe service worker will be uninstalled. Note that depending on how `/service-worker.js` is served,\nit may take up to 24 hours for the cache to be invalidated.\n\n### Offline-First Considerations\n\n1. Service workers [require HTTPS](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers#you_need_https),\nalthough to facilitate local testing, that policy\n[does not apply to `localhost`](http://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http/34161385#34161385).\nIf your production web server does not support HTTPS, then the service worker\nregistration will fail, but the rest of your web app will remain functional.\n\n1. Service workers are [not currently supported](https://jakearchibald.github.io/isserviceworkerready/)\nin all web browsers. Service worker registration [won't be attempted](src/registerServiceWorker.js)\non browsers that lack support.\n\n1. The service worker is only enabled in the [production environment](#deployment),\ne.g. the output of `npm run build`. It's recommended that you do not enable an\noffline-first service worker in a development environment, as it can lead to\nfrustration when previously cached assets are used and do not include the latest\nchanges you've made locally.\n\n1. If you *need* to test your offline-first service worker locally, build\nthe application (using `npm run build`) and run a simple http server from your\nbuild directory. After running the build script, `create-react-app` will give\ninstructions for one way to test your production build locally and the [deployment instructions](#deployment) have\ninstructions for using other methods. *Be sure to always use an\nincognito window to avoid complications with your browser cache.*\n\n1. If possible, configure your production environment to serve the generated\n`service-worker.js` [with HTTP caching disabled](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours).\nIf that's not possible—[GitHub Pages](#github-pages), for instance, does not\nallow you to change the default 10 minute HTTP cache lifetime—then be aware\nthat if you visit your production site, and then revisit again before\n`service-worker.js` has expired from your HTTP cache, you'll continue to get\nthe previously cached assets from the service worker. If you have an immediate\nneed to view your updated production deployment, performing a shift-refresh\nwill temporarily disable the service worker and retrieve all assets from the\nnetwork.\n\n1. Users aren't always familiar with offline-first web apps. It can be useful to\n[let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)\nwhen the service worker has finished populating your caches (showing a \"This web\napp works offline!\" message) and also let them know when the service worker has\nfetched the latest updates that will be available the next time they load the\npage (showing a \"New content is available; please refresh.\" message). Showing\nthis messages is currently left as an exercise to the developer, but as a\nstarting point, you can make use of the logic included in [`src/registerServiceWorker.js`](src/registerServiceWorker.js), which\ndemonstrates which service worker lifecycle events to listen for to detect each\nscenario, and which as a default, just logs appropriate messages to the\nJavaScript console.\n\n1. By default, the generated service worker file will not intercept or cache any\ncross-origin traffic, like HTTP [API requests](#integrating-with-an-api-backend),\nimages, or embeds loaded from a different domain. If you would like to use a\nruntime caching strategy for those requests, you can [`eject`](#npm-run-eject)\nand then configure the\n[`runtimeCaching`](https://github.com/GoogleChrome/sw-precache#runtimecaching-arrayobject)\noption in the `SWPrecacheWebpackPlugin` section of\n[`webpack.config.prod.js`](../config/webpack.config.prod.js).\n\n### Progressive Web App Metadata\n\nThe default configuration includes a web app manifest located at\n[`public/manifest.json`](public/manifest.json), that you can customize with\ndetails specific to your web application.\n\nWhen a user adds a web app to their homescreen using Chrome or Firefox on\nAndroid, the metadata in [`manifest.json`](public/manifest.json) determines what\nicons, names, and branding colors to use when the web app is displayed.\n[The Web App Manifest guide](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/)\nprovides more context about what each field means, and how your customizations\nwill affect your users' experience.\n\n## Deployment\n\n\n`elm-app build` creates a `build` directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main.\u003chash\u003e.js` are served with the contents of the `/static/js/main.\u003chash\u003e.js` file.\n\n### Building for Relative Paths\n\nBy default, Create Elm App produces a build assuming your app is hosted at the server root.\u003cbr\u003e\nTo override this, specify the `homepage` in your `elm-package.json`, for example:\n\n```js\n  \"homepage\": \"http://mywebsite.com/relativepath\",\n```\n\nThis will let Create Elm App correctly infer the root path to use in the generated HTML file.\n\n### Static Server\n\nFor environments using [Node](https://nodejs.org/), the easiest way to handle this would be to install [serve](https://github.com/zeit/serve) and let it handle the rest:\n\n```sh\nnpm install -g serve\nserve -s build\n```\n\nThe last command shown above will serve your static site on the port **5000**. Like many of [serve](https://github.com/zeit/serve)’s internal settings, the port can be adjusted using the `-p` or `--port` flags.\n\nRun this command to get a full list of the options available:\n\n```sh\nserve -h\n```\n\n### GitHub Pages\n\n#### Step 1: Add `homepage` to `elm-package.json`\n\n**The step below is important!**\u003cbr\u003e\n**If you skip it, your app will not deploy correctly.**\n\nOpen your `elm-package.json` and add a `homepage` field:\n\n```js\n  \"homepage\": \"https://myusername.github.io/my-app\",\n```\n\nCreate Elm App uses the `homepage` field to determine the root URL in the built HTML file.\n\n#### Step 2: Build the static site\n\n```sh\nelm-app build\n```\n\n#### Step 3: Deploy the site by running `gh-pages -d build`\n\nWe will use [gh-pages](https://www.npmjs.com/package/gh-pages) to upload the files from the `build` directory to GitHub. If you haven't already installed it, do so now (`npm install -g gh-pages`)\n\nNow run:\n\n```sh\ngh-pages -d build\n```\n\n#### Step 4: Ensure your project’s settings use `gh-pages`\n\nFinally, make sure **GitHub Pages** option in your GitHub project settings is set to use the `gh-pages` branch:\n\n\u003cimg src=\"http://i.imgur.com/HUjEr9l.png\" width=\"500\" alt=\"gh-pages branch setting\"\u003e\n\n#### Step 5: Optionally, configure the domain\n\nYou can configure a custom domain with GitHub Pages by adding a `CNAME` file to the `public/` folder.\n\n#### Notes on client-side routing\n\nGitHub Pages doesn’t support routers that use the HTML5 `pushState` history API under the hood (for example, React Router using `browserHistory`). This is because when there is a fresh page load for a url like `http://user.github.io/todomvc/todos/42`, where `/todos/42` is a frontend route, the GitHub Pages server returns 404 because it knows nothing of `/todos/42`. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions:\n\n* You could switch from using HTML5 history API to routing with hashes.\n* Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your `index.html` page with a special redirect parameter. You would need to add a `404.html` file with the redirection code to the `build` folder before deploying your project, and you’ll need to add code handling the redirect parameter to `index.html`. You can find a detailed explanation of this technique [in this guide](https://github.com/rafrex/spa-github-pages).\n\n## IDE setup for Hot Module Replacement\n\nRemember to disable [safe write](https://webpack.github.io/docs/webpack-dev-server.html#working-with-editors-ides-supporting-safe-write) if you are using VIM or IntelliJ IDE, such as WebStorm.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeizer%2Ftodo-elm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxbeizer%2Ftodo-elm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxbeizer%2Ftodo-elm/lists"}