dwyl / learn-phoenix-framework

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
648 stars 45 forks source link

Should we be using brunch in our apps #111

Closed samhstn closed 5 years ago

samhstn commented 6 years ago

Phoenix comes quite nicely set up with brunch, but it may be overkill, more work to configure and giving us less control over our static assets.

Another option is to instead set up our development server to watch npm commands instead of the default brunch stuff which ends up in our config/dev.exs.

When building for the prod environment we would have more control over how our static assets are built. This would require more work, but should be easier to debug and optimise.

nelsonic commented 6 years ago

@shouston3 yeah, I was thinking the same thing the other day, might Brunch be "too much". What is the most "basic" way of compiling an Elm app for use with a Phoenix backend?

samhstn commented 6 years ago

Most basic in terms of quick start is just the default brunch configuration.

Most basic in terms of least technologies would be something like:

node_modules/.bin/elm make Main.elm --output $PATH_TO_PHX_WEB_DIR/priv/static/js/app.js
nelsonic commented 6 years ago

@shouston3 will that "live/hot reload" the app.js in the Browser?

samhstn commented 6 years ago

That command alone won't, but all you need to do from there add an npm command to do the above, then edit your config/dev.exs file run that command, something like:

...
check_origin: false,
watchers = [{:npm, ["run", "watch:elm", cd: Path.expand("../assets", __DIR__)]}]
samhstn commented 6 years ago

I have a working example here: https://github.com/shouston3/pete_boilerplate/tree/master/pete_auth

nelsonic commented 6 years ago

Thanks for adding link @shouston3, will take a look at it. 👍

nelsonic commented 5 years ago

GOTO: #118 (Phoenix 1.4 Uses Webpack so Brunch is no longer a "question" for new users. closing)