CargoSense / dart_sass

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

Only two positional args may be passed. #23

Closed conradwt closed 2 years ago

conradwt commented 2 years ago

When I run mix sass default assets/css/app.scss priv/static/assets/app.css, I'm seeing the following within the terminal:

Only two positional args may be passed.

Usage: sass <input.scss> [output.css]
       sass <input.scss>:<output.css> <input/>:<output/> <dir/>

When I remove the default and use mix sass assets/css/app.scss priv/static/assets/app.css, I see the following within the terminal:

** (ArgumentError) unknown dart_sass profile. Make sure the profile is defined in your config files, such as:

    config :dart_sass,
      assets/css/app.scss: [
        args: ~w(css/app.scss ../priv/static/assets/app.css),
        cd: Path.expand("../assets", __DIR__)
      ]

    (dart_sass 0.4.0) lib/dart_sass.ex:105: DartSass.config_for!/1
    (dart_sass 0.4.0) lib/dart_sass.ex:176: DartSass.run/2
    (dart_sass 0.4.0) lib/mix/tasks/sass.ex:47: Mix.Tasks.Sass.install_and_run/1
    (mix 1.13.3) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.13.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2

Finally, I have defined the following profile within the config/config.exs file:

config :dart_sass,
  version: "1.49.9",
  default: [
    args: ~w(css/app.scss ../priv/static/assets/app.css),
    cd: Path.expand("../assets", __DIR__)
  ]

Using the following dependencies:

Phoenix 1.6.6 Elixir 1.13.3 Erlang 24.2.2

mcrumm commented 2 years ago

Hi @conradwt, the config example in the error message is wrong 🙈 Sorry you had to deal with that, I will fix it right away!

First thing, you need a colon between the input asset and the output filename. Change your config to the following:

config :dart_sass,
  version: "1.49.9",
  default: [
    args: ~w(css/app.scss:../priv/static/assets/app.css),
    cd: Path.expand("../assets", __DIR__)
  ]

...or you can simplify slightly by using directory names (this is my preference):

config :dart_sass,
  version: "1.49.9",
  default: [
    args: ~w(css:../priv/static/assets),
    cd: Path.expand("../assets", __DIR__)
  ]

Second thing, you won't need to include the asset filenames when you run the sass task because they are included in the config :) So you can run it like this:

$ mix sass default

The config difference is really subtle, and I think the first error message you received added more confusion because it came from the sass binary and not directly from this package, and then the second error message outright lied to you :)