CargoSense / dart_sass

Install and run Dart Sass using Elixir.
https://hex.pm/packages/dart_sass
MIT License
104 stars 23 forks source link

Make runtime config optional #8

Closed objectuser closed 3 years ago

objectuser commented 3 years ago

We're doing the assets.deploy step using dart_sass in a Dockerfile and don't want the runtime.exs configuration to be required (DB config vars and the like).

Looking at esbuild, it has that as an option:

https://github.com/phoenixframework/esbuild/blob/d4cf71f62f6c01234f8ab2d39467f1cce8dbeee7/lib/mix/tasks/esbuild.ex#L34-L46

Wondering if that's viable for dart_sass? Something like:

  def run([profile | args] = all) do
    switches = [runtime_config: :boolean]
    {opts, remaining_args} = OptionParser.parse_head!(args, switches: switches)

    if opts[:runtime_config] do
      Mix.Task.run("app.config")
    else
      Application.ensure_all_started(:dart_sass)
    end

    case DartSass.install_and_run(String.to_atom(profile), remaining_args) do
      0 -> :ok
      status -> Mix.raise("`mix sass #{Enum.join(all, " ")}` exited with #{status}")
    end

    Mix.Task.reenable("sass")
  end

Thanks!

mcrumm commented 3 years ago

@objectuser Yes, definitely viable! A PR would be very welcome :)

objectuser commented 3 years ago

@mcrumm Great, created #9.