LoginSignup
19
16

More than 5 years have passed since last update.

Brunch 有り/無しで Phoenix プロジェクトを生成してファイルの差分を見てみた

Last updated at Posted at 2015-08-25

mix phoenix.new PATH--no-brunch を渡すか渡さないかで生成されるプロジェクトがどう変わるかが気になったので調べた。

同名のプロジェクトを2つ、 Brunch 有りと無しで生成して git diff で差分を取った。

生成して差分を取るスクリプト
mkdir without_brunch with_brunch
( cd without_brunch ; yes n | mix phoenix.new sample --no-brunch )
( cd with_brunch    ; yes n | mix phoenix.new sample )
git diff --no-index --stat without_brunch with_brunch
差分
 {without_brunch => with_brunch}/sample/.gitignore  |   10 +-
 /dev/null => with_brunch/sample/brunch-config.js   |   66 ++
 .../sample/config/config.exs                       |    2 +-
 .../sample/config/dev.exs                          |    2 +-
 .../sample/config/prod.secret.exs                  |    2 +-
 .../sample/lib/sample/endpoint.ex                  |    2 +-
 /dev/null => with_brunch/sample/package.json       |   12 +
 .../sample/priv/static/css/app.css => /dev/null    |   80 --
 .../sample/priv/static/favicon.ico => /dev/null    |  Bin 1258 -> 0 bytes
 .../priv/static/images/phoenix.png => /dev/null    |  Bin 13900 -> 0 bytes
 .../sample/priv/static/js/app.js => /dev/null      |    0
 .../sample/priv/static/js/phoenix.js => /dev/null  | 1196 --------------------
 .../sample/priv/static/robots.txt => /dev/null     |    5 -
 .../sample/web/static/assets/favicon.ico           |  Bin 0 -> 1258 bytes
 .../sample/web/static/assets/images/phoenix.png    |  Bin 0 -> 13900 bytes
 .../sample/web/static/assets/robots.txt            |    5 +
 .../sample/web/static/css/app.css                  |   80 ++
 .../sample/web/static/js/app.js                    |   21 +
 .../sample/web/static/js/socket.js                 |   62 +
 19 files changed, 259 insertions(+), 1286 deletions(-)

結果、 Brunch との統合を有効にすると、無効のものに比べて:

  • brunch-config.js と package.json が追加されている
  • .gitignore で web/static が無視されている
  • web/static にあったファイルが priv/static に移動されている
  • config/dev.exs で watcher の設定が追加されている

(config/{config,prod.secret}.exs, lib/$module/endpoint.ex の差分はランダムなトークン文字列の変化によるもので Brunch の有無とは関係ない)

config/dev.exs の差分の内容は以下のとおり:

diff --git a/without_brunch/sample/config/dev.exs b/with_brunch/sample/config/dev.exs
index e3f59b8..b5c7bb7 100644
--- a/without_brunch/sample/config/dev.exs
+++ b/with_brunch/sample/config/dev.exs
@@ -11,7 +11,7 @@ config :sample, Sample.Endpoint,
   debug_errors: true,
   code_reloader: true,
   cache_static_lookup: false,
-  watchers: []
+  watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]]

 # Watch static and templates for browser reloading.
 config :sample, Sample.Endpoint,

watchers オプションの値は [{command, [args...]}, ...] の形式のリスト。 mix phoenix.server でサーバを起動すると指定したコマンドを実行する。

19
16
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
19
16