Good example of plug based web application

This is mentioned often and I wonder if simply highlighting the --no-* options in the getting started guide would help, because a lot of Phoenix is optional:

  • --no-assets - equivalent to --no-esbuild and --no-tailwind
  • --no-dashboard - do not include Phoenix.LiveDashboard
  • --no-ecto - do not generate Ecto files
  • --no-esbuild - do not include esbuild dependencies and assets. We do not recommend setting this option, unless for API only applications, as doing so requires you to manually add and track JavaScript dependencies
  • --no-gettext - do not generate gettext files
  • --no-html - do not generate HTML views
  • --no-live - comment out LiveView socket setup in assets/js/app.js. Automatically disabled if --no-html is given
  • --no-mailer - do not generate Swoosh mailer files
  • --no-tailwind - do not include tailwind dependencies and assets. The generated markup will still include Tailwind CSS classes, those are left-in as reference for the subsequent styling of your layout and components

Edit: these are the files created when you use all those flags:

mix phx.new phoenix_lite_example --no-assets --no-dashboard --no-ecto --no-gettext --no-html --no-mailer
* creating phoenix_lite_example/lib/phoenix_lite_example/application.ex
* creating phoenix_lite_example/lib/phoenix_lite_example.ex
* creating phoenix_lite_example/lib/phoenix_lite_example_web/controllers/error_json.ex
* creating phoenix_lite_example/lib/phoenix_lite_example_web/endpoint.ex
* creating phoenix_lite_example/lib/phoenix_lite_example_web/router.ex
* creating phoenix_lite_example/lib/phoenix_lite_example_web/telemetry.ex
* creating phoenix_lite_example/lib/phoenix_lite_example_web.ex
* creating phoenix_lite_example/mix.exs
* creating phoenix_lite_example/README.md
* creating phoenix_lite_example/.formatter.exs
* creating phoenix_lite_example/.gitignore
* creating phoenix_lite_example/test/support/conn_case.ex
* creating phoenix_lite_example/test/test_helper.exs
* creating phoenix_lite_example/test/phoenix_lite_example_web/controllers/error_json_test.exs
* creating phoenix_lite_example/priv/static/robots.txt
* creating phoenix_lite_example/priv/static/favicon.ico

Edit 2: These are the dependencies included:

  • phoenix
  • telemetry_metrics
  • telemetry_poller
  • jason
  • dns_cluster
  • bandit

And the extra dependencies in lockfile:

  • castore
  • hpax
  • mime
  • phoenix_pubsub
  • phoenix_template
  • plug
  • plug_crypto
  • telemetry
  • thousand_island
  • websock
  • websock_adapter

So apart from adding a --no-telemetry flag I’m not sure how much lighter it could reasonably get while still being sensible?

3 Likes