LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

elm-makeについて調べたこと

Last updated at Posted at 2016-12-04

elm-makeとは

  • .elmのコードをビルドするのに使う
  • 出力されるファイルは、.jsファイルが基本
  • htmlとjsまとめて出力(.jsは埋め込み、初期化コード入れた状態で)する設定とかもある
    • ex elm-make Main.elm --output=main.html

elm-reactorとどう違う?

  • elm-reactorはビルド用途としては、ビギナー向け
    • zero configurationでビルドする用途
    • easy to startを体現したツール
  • プロダクション利用では、elm-makeを使うことになる
  • elm-reactorには実はビルド用途以外としては、time travel debuggerとかキラー機能があるが、..(略)

elm-make ? elm make ?

  • どっちでも動く
  • elm-reqpl, elm-package, elm-reactor も同じ挙動
  • elmコマンドは単独では何もしない(ヘルプ的なメッセージを出すだけ)
    • version、組み合わせるサブコマンド(make, packgeなど)を列挙してくれる
Elm Platform 0.18.0 - a way to run all Elm tools

Usage: elm <command> [<args>]

Available commands include:

  make      Compile an Elm file or project into JS or HTML
  package   Manage packages from <http://package.elm-lang.org>
  reactor   Develop with compile-on-refresh and time-travel debugging
  repl      A REPL for running individual expressions

You can learn more about a specific command by running things like:

  elm make --help
  elm package --help
  elm <command> --help

In all these cases we are simply running 'elm-<command>' so if you create an
executable named 'elm-foobar' you will be able to run it as 'elm foobar' as
long as it appears on your PATH.

elm-makeのdocument的なもの

基本の使い方

elm make -hの出力結果を確認する

elm-make 0.18 (Elm Platform 0.18.0)

Usage: elm-make [FILES...] [--output FILE] [--yes] [--report FORMAT] [--debug]
                [--warn] [--docs FILE] [--prepublish] [--prepublish-core]
  build Elm projects

Available options:
  -h,--help                Show this help text
  --output FILE            Write result to the given .html or .js FILE.
  --yes                    Reply 'yes' to all automated prompts.
  --report FORMAT          Format of error and warning reports (e.g.
                           --report=json)
  --debug                  Generate programs in debug mode.
  --warn                   Report warnings to improve code quality.
  --docs FILE              Write documentation to FILE as JSON.

Examples:
  elm-make Main.elm                     # compile to HTML in index.html
  elm-make Main.elm --output main.html  # compile to HTML in main.html
  elm-make Main.elm --output elm.js     # compile to JS in elm.js
  elm-make Main.elm --warn              # compile and report warnings

Full guide to using elm-make at <https://github.com/elm-lang/elm-make>

ブログやgithubでいちばんみかけるのは、

 elm-make [FILES...] [--output FILE]

という形式

elm-make src/elm/Page/Main.elm --output=index.js

--output オプション

elm-make src/elm/Page/Main.elm --output=index.js
elm-make Main.elm --output=main.html
  • 出力するファイル名を指定。htmlかjsかを選べる

--yes オプション

elm-make src/elm/Page/Main.elm --output=index.js  --yes
  • Elmプロジェクトを最初にセットアップするときとかにみかける対話型シェルに事前にyesと答えるやつ
  • プロジェクトが依存するelmパッケージをインストールとかを確認しないでスタートしたいときとか

--warn オプション

elm-make src/elm/Page/Map/Main.elm --output=index.js --warn

型定義書かないでコンパイルした箇所に、型定義をサジェストしてくれる

elm-make PhotoGroove.elm --output elm.js --warn
You should see this warning:

Top-level value `main` does not have a type annotation.
 
139| main =
     ^^^^
I inferred the type annotation so you can copy it into your code:
 
main : Program Never Model Msg

--report, --doc オプション

  • 試したことない(あとで調べる)

--debug

  • v0.18のキラー機能であるデバッガーを使うためのフラグ
  • pragmatic studioに3分のミニビデオチュートリアルがある
  • blogみてもイメージ湧かなかったが、動画みてこれはすごいと感動できた
    • perfect bug report、とEvanが入ってるのも納得した
    • 画面の操作履歴をファイルに出力して、出力を共有すると、挙動が再現できる、というものらしい

--
現時点で試してないものはあとで追記予定

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up