Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying as a standalone page

Tags:

deployment

elm

During the development process, I've been using elm-reactor to test my one-page Elm application. But for production deployment, I would like to just store the compiler's output as static files on a webserver.

How do I compile an Elm page into a standalone pair of HTML + Javascript files?

like image 281
Cactus Avatar asked Jan 24 '15 10:01

Cactus


1 Answers

  1. Use elm-make to compile your Elm application to elm.js (target the module that defines main).
  2. Create your own HTML file that includes that script and a script in the body that executes Elm.<Module-that-defines-main>.fullscreen()

Example

App.elm

module App where

import Text
import Signal
import Graphics.Element (Element)

main : Signal Element
main = "Hello World!" |> Text.asText |> Signal.constant

elm-make App.elm (creates elm.js)

App.html

<!DOCTYPE html>
<html>
 <head>
  <script src="elm.js" type="text/javascript"></script>
 </head>
 <body>
  <script type="text/javascript">Elm.App.fullscreen()</script>
 </body>
</html>
like image 132
Apanatshka Avatar answered Oct 28 '22 02:10

Apanatshka