Skip to content

Instantly share code, notes, and snippets.

@addywaddy
Last active August 30, 2018 09:36
Show Gist options
  • Save addywaddy/9c8b39f6660cb19c7ac749a4199d500e to your computer and use it in GitHub Desktop.
Save addywaddy/9c8b39f6660cb19c7ac749a4199d500e to your computer and use it in GitHub Desktop.
Elm loader update for 1.9
diff --git a/config/webpack/loaders/elm.js b/config/webpack/loaders/elm.js
index d4c175e..9d88480 100644
--- a/config/webpack/loaders/elm.js
+++ b/config/webpack/loaders/elm.js
@@ -2,12 +2,11 @@ const { resolve } = require('path')
const isProduction = process.env.NODE_ENV === 'production'
const elmSource = resolve(process.cwd())
-const elmMake = `${elmSource}/node_modules/.bin/elm-make`
+const elm = `${elmSource}/node_modules/.bin/elm`
-const elmDefaultOptions = { cwd: elmSource, pathToMake: elmMake }
+const elmDefaultOptions = { cwd: elmSource, pathToElm: elm }
const developmentOptions = Object.assign({}, elmDefaultOptions, {
verbose: true,
- warn: true,
debug: true
})
@@ -19,5 +18,5 @@ const elmWebpackLoader = {
module.exports = {
test: /\.elm(\.erb)?$/,
exclude: [/elm-stuff/, /node_modules/],
- use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-loader' }, elmWebpackLoader]
+ use: isProduction ? [elmWebpackLoader] : [{ loader: 'elm-hot-webpack-loader' }, elmWebpackLoader]
}
diff --git a/app/javascript/Main.elm b/app/javascript/Main.elm
index 7b2be6c..f5c7b74 100644
--- a/app/javascript/Main.elm
+++ b/app/javascript/Main.elm
@@ -1,54 +1,69 @@
module Main exposing (..)
+import Browser
import Html exposing (Html, h1, text)
import Html.Attributes exposing (style)
+
-- MODEL
+
type alias Model =
- {
- }
+ {}
+
+
-- INIT
-init : (Model, Cmd Message)
-init =
- (Model, Cmd.none)
+
+init : () -> ( Model, Cmd Message )
+init _ =
+ ( Model, Cmd.none )
+
+
-- VIEW
+
view : Model -> Html Message
view model =
- -- The inline style is being used for example purposes in order to keep this example simple and
- -- avoid loading additional resources. Use a proper stylesheet when building your own app.
- h1 [style [("display", "flex"), ("justify-content", "center")]]
- [text "Hello Elm!"]
+ h1 [] [ text "Hello Elm!" ]
+
+
-- MESSAGE
+
type Message
- = None
+ = None
+
+
-- UPDATE
-update : Message -> Model -> (Model, Cmd Message)
+
+update : Message -> Model -> ( Model, Cmd Message )
update message model =
- (model, Cmd.none)
+ ( model, Cmd.none )
+
+
-- SUBSCRIPTIONS
diff --git a/app/javascript/Main.elm b/app/javascript/Main.elm
index 7b2be6c..f5c7b74 100644
--- a/app/javascript/Main.elm
+++ b/app/javascript/Main.elm
@@ -1,54 +1,69 @@
module Main exposing (..)
+import Browser
import Html exposing (Html, h1, text)
import Html.Attributes exposing (style)
+
-- MODEL
+
type alias Model =
- {
- }
+ {}
+
+
-- INIT
-init : (Model, Cmd Message)
-init =
- (Model, Cmd.none)
+
+init : () -> ( Model, Cmd Message )
+init _ =
+ ( Model, Cmd.none )
+
+
-- VIEW
+
view : Model -> Html Message
view model =
- -- The inline style is being used for example purposes in order to keep this example simple and
- -- avoid loading additional resources. Use a proper stylesheet when building your own app.
- h1 [style [("display", "flex"), ("justify-content", "center")]]
- [text "Hello Elm!"]
+ h1 [] [ text "Hello Elm!" ]
+
+
-- MESSAGE
+
type Message
- = None
+ = None
+
+
-- UPDATE
-update : Message -> Model -> (Model, Cmd Message)
+
+update : Message -> Model -> ( Model, Cmd Message )
update message model =
- (model, Cmd.none)
+ ( model, Cmd.none )
+
+
-- SUBSCRIPTIONS
+
subscriptions : Model -> Sub Message
subscriptions model =
- Sub.none
+ Sub.none
+
+
-- MAIN
-main : Program Never Model Message
+
main =
- Html.program
- {
- init = init,
- view = view,
- update = update,
- subscriptions = subscriptions
- }
+ Browser.element
+ { init = init
+ , view = view
+ , update = update
+ , subscriptions = subscriptions
+ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment