Skip to content

Instantly share code, notes, and snippets.

@forficate
Forked from dpwiz/Main.elm
Created October 1, 2015 15:02
Render, minify and compress Elm project.
module Main where
import Html (..)
import Html.Attributes (..)
import Html.Events (..)
import List
import LocalChannel as LC
import Signal
-- Model
type alias Model =
{ thingy : String
}
init : Model
init =
{ thingy = "Hellow, orld!"
}
-- Update
type Action = NoOp
update : Action -> Model -> Model
update action model =
case action of
NoOp -> model
-- View
view : Model -> Html
view model =
div [] [ text model.thingy ]
-- Signals
main : Signal Html
main = Signal.map view model
model : Signal Model
model = Signal.foldp update init (Signal.subscribe actionChannel)
actionChannel : Signal.Channel Action
actionChannel = Signal.channel NoOp
ELM=elm-make
CLOSURE=java -jar compiler.jar
CLOSURE_FLAGS=-O ADVANCED --language_in ECMASCRIPT5 --jscomp_off globalThis
ELM_SRC=elm
STATIC_JS=static/js
default: elm
elm: $(STATIC_JS)/elm.min.js.gz
$(STATIC_JS)/elm.min.js.gz: $(STATIC_JS)/elm.min.js
gzip -f -k -9 $(STATIC_JS)/elm.min.js
$(STATIC_JS)/elm.min.js: $(ELM_SRC)/elm.js
$(CLOSURE) $(CLOSURE_FLAGS) --js $(ELM_SRC)/elm.js --js_output_file $(STATIC_JS)/elm.min.js
$(ELM_SRC)/elm.js: $(ELM_SRC)/Main.elm
cd $(ELM_SRC) && $(ELM) Main.elm
.PHONY: clean
clean:
rm $(ELM_SRC)/elm.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment