Commit d9aa8f508b8adac414c7ba3597950b06687a44da

Michael Crumm 2021-07-23T17:30:58

install and run dart-sass

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
diff --git a/LICENSE.md b/LICENSE.md
index 6568d08..2db2a1c 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,6 +1,6 @@
 # MIT License
 
-Copyright (c) 2021 Wojtek Mach, José Valim.
+Copyright (c) 2021 CargoSense, Inc.
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
diff --git a/README.md b/README.md
index 6f13529..8a93d07 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,19 @@
-# Esbuild
+# DartSass
 
-[![CI](https://github.com/phoenixframework/esbuild/actions/workflows/main.yml/badge.svg)](https://github.com/phoenixframework/esbuild/actions/workflows/main.yml)
+[![CI](https://github.com/CargoSense/dart_sass/actions/workflows/main.yml/badge.svg)](https://github.com/CargoSense/dart_sass/actions/workflows/main.yml)
 
-Mix tasks for installing and invoking [esbuild](https://github.com/evanw/esbuild/).
+Mix tasks for installing and invoking [sass](https://github.com/sass/dart-sass/).
 
 ## Installation
 
 If you are going to build assets in production, then you add
-`esbuild` as dependency on all environments but only start it
+`dart_sass` as a dependency on all environments but only start it
 in dev:
 
 ```elixir
 def deps do
   [
-    {:esbuild, "~> 0.1", runtime: Mix.env() == :dev}
+    {:dart_sass, "~> 0.1", runtime: Mix.env() == :dev}
   ]
 end
 ```
@@ -24,54 +24,63 @@ then it only needs to be a dev dependency:
 ```elixir
 def deps do
   [
-    {:esbuild, "~> 0.1", only: :dev}
+    {:dart_sass, "~> 0.1", only: :dev}
   ]
 end
 ```
 
 Once installed, change your `config/config.exs` to pick your
-esbuild version of choice:
+dart_sass version of choice:
 
 ```elixir
-config :esbuild, version: "0.12.15"
+config :dart_sass, version: "1.36.0"
 ```
 
-Now you can install esbuild by running:
+Now you can install dart_sass by running:
 
 ```bash
-$ mix esbuild.install
+$ mix dart_sass.install
 ```
 
-And invoke esbuild with:
+And invoke dart_sass with:
 
 ```bash
-$ mix esbuild default assets/js/app.js --bundle --minify --target=es2016 --outdir=priv/static/assets/
+$ mix dart_sass default assets/css/app.scss priv/static/assets/app.css
 ```
 
-The executable is kept at `_build/esbuild`.
+If you need additional load paths you may specify them:
+
+```bash
+$ mix dart_sass default assets/css/app.scss -I assets/node_modules/bulma priv/static/assets/app.css
+```
+
+The executable is kept at `_build/sass`.
 
 ### Profiles
 
-The first argument to `esbuild` is the execution profile.
+The first argument to `dart_sass` is the execution profile.
 You can define multiple execution profiles with the current
-directory, the OS enviroment, and default arguments to the
-`esbuild` task:
+directory, the OS environment, and default arguments to the
+`dart_sass` task:
 
 ```elixir
-config :esbuild,
-  version: "0.12.15",
+config :dart_sass,
+  version: "1.36.0",
   default: [
-    args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
-    cd: Path.expand("../assets", __DIR__),
-    env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
+    args: ~w(css/app.scss ../priv/static/assets/app.css),
+    cd: Path.expand("../assets", __DIR__)
   ]
 ```
 
-When `mix esbuild default` is invoked, the task arguments will be appended
+When `mix sass default` is invoked, the task arguments will be appended
 to the ones configured above.
 
+## Acknowledgements
+
+This package is based on the excellent [esbuild](https://github.com/phoenixframework/esbuild) by Wojtek Mach and José Valim.
+
 ## License
 
-Copyright (c) 2021 Wojtek Mach, José Valim.
+Copyright (c) 2021 CargoSense, Inc.
 
-esbuild source code is licensed under the [MIT License](LICENSE.md).
+dart_sass source code is licensed under the [MIT License](LICENSE.md).
diff --git a/config/config.exs b/config/config.exs
index 899846a..083c135 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -1,7 +1,7 @@
 import Config
 
-config :esbuild,
-  version: "0.12.15",
+config :dart_sass,
+  version: "1.36.0",
   another: [
     args: ["--version"]
   ]
diff --git a/lib/dart_sass.ex b/lib/dart_sass.ex
new file mode 100644
index 0000000..5c1aeca
--- /dev/null
+++ b/lib/dart_sass.ex
@@ -0,0 +1,249 @@
+defmodule DartSass do
+  @moduledoc """
+  DartSass is a installer and runner for [sass](https://sass-lang.com/dart-sass).
+
+  ## Profiles
+
+  You can define multiple dart_sass profiles. By default, there is a
+  profile called `:default` which you can configure its args, current
+  directory and environment:
+
+      config :dart_sass,
+        version: "1.36.0",
+        default: [
+          args: ~w(css/app.scss ../priv/static/assets/app.css),
+          cd: Path.expand("../assets", __DIR__)
+        ]
+  """
+
+  use Application
+  require Logger
+
+  @doc false
+  def start(_, _) do
+    unless Application.get_env(:dart_sass, :version) do
+      Logger.warn("""
+      dart_sass version is not configured. Please set it in your config files:
+
+          config :dart_sass, :version, "#{latest_version()}"
+      """)
+    end
+
+    configured_version = configured_version()
+
+    case bin_version() do
+      {:ok, ^configured_version} ->
+        :ok
+
+      {:ok, version} ->
+        Logger.warn("""
+        Outdated dart-sass version. Expected #{configured_version}, got #{version}. \
+        Please run `mix sass.install` or update the version in your config files.\
+        """)
+
+      :error ->
+        :ok
+    end
+
+    Supervisor.start_link([], strategy: :one_for_one)
+  end
+
+  @doc false
+  # Latest known version at the time of publishing.
+  def latest_version do
+    "1.36.0"
+  end
+
+  @doc """
+  Returns the configured dart_sass version.
+  """
+  def configured_version do
+    Application.get_env(:dart_sass, :version, latest_version())
+  end
+
+  @doc """
+  Returns the configuration for the given profile.
+
+  Returns nil if the profile does not exist.
+  """
+  def config_for!(profile) when is_atom(profile) do
+    Application.get_env(:dart_sass, profile) ||
+      raise ArgumentError, """
+      unknown dart_sass profile. Make sure the profile is defined in your config files, such as:
+
+          config :dart_sass,
+            #{profile}: [
+              args: ~w(css/app.scss ../priv/static/assets/app.css),
+              cd: Path.expand("../assets", __DIR__)
+            ]
+      """
+  end
+
+  @doc """
+  Returns the path to the executable.
+
+  The executable may not be available if it was not yet installed.
+  """
+  def bin_path do
+    Path.join(Path.dirname(Mix.Project.build_path()), "sass")
+  end
+
+  def vm_path do
+    Path.join(Path.dirname(Mix.Project.build_path()), "dart")
+  end
+
+  def snapshot_path do
+    Path.join(Path.dirname(Mix.Project.build_path()), "sass.snapshot")
+  end
+
+  def sass_cmd do
+    case :os.type() do
+      {:unix, :darwin} -> {vm_path(), [snapshot_path()]}
+      {:win32, _} -> {vm_path(), [snapshot_path()]}
+      _ -> {bin_path(), []}
+    end
+  end
+
+  @doc """
+  Returns the version of the dart_sass executable.
+
+  Returns `{:ok, version_string}` on success or `:error` when the executable
+  is not available.
+  """
+  def bin_version do
+    {path, args} = sass_cmd()
+
+    with true <- File.exists?(path),
+         {result, 0} <- System.cmd(path, args ++ ["--version"]) do
+      {:ok, String.trim(result)}
+    else
+      _ -> :error
+    end
+  end
+
+  @doc """
+  Runs the given command with `args`.
+
+  The given args will be appended to the configured args.
+  The task output will be streamed directly to stdio. It
+  returns the status of the underlying call.
+  """
+  def run(profile, extra_args) when is_atom(profile) and is_list(extra_args) do
+    config = config_for!(profile)
+    args = config[:args] || []
+
+    opts = [
+      cd: config[:cd] || File.cwd!(),
+      env: config[:env] || %{},
+      into: IO.stream(:stdio, :line),
+      stderr_to_stdout: true
+    ]
+
+    {bin_path, bin_args} = sass_cmd()
+
+    bin_path
+    |> System.cmd(bin_args ++ args ++ extra_args, opts)
+    |> elem(1)
+  end
+
+  @doc """
+  Installs, if not available, and then runs `dart_sass`.
+
+  Returns the same as `run/2`.
+  """
+  def install_and_run(profile, args) do
+    bin_path = DartSass.bin_path()
+
+    unless File.exists?(bin_path) do
+      install()
+    end
+
+    run(profile, args)
+  end
+
+  @doc """
+  Installs dart_sass with `configured_version/0`.
+  """
+  def install do
+    version = DartSass.configured_version()
+    tmp_dir = Path.join(System.tmp_dir!(), "cs-dart-sass")
+    File.rm_rf!(tmp_dir)
+    File.mkdir_p!(tmp_dir)
+
+    name = "dart-sass-#{version}-#{target()}"
+    url = "https://github.com/sass/dart-sass/releases/download/#{version}/#{name}"
+    tar = fetch_body!(url)
+
+    case :erl_tar.extract({:binary, tar}, [:compressed, cwd: tmp_dir]) do
+      :ok -> :ok
+      other -> raise "couldn't unpack archive: #{inspect(other)}"
+    end
+
+    bin_path = DartSass.bin_path()
+    snapshot_path = DartSass.snapshot_path()
+    vm_path = DartSass.vm_path()
+
+    case :os.type() do
+      {:win32, _} ->
+        File.cp!(Path.join([tmp_dir, "dart-sass", "src", "dart.exe"]), vm_path)
+        File.cp!(Path.join([tmp_dir, "dart-sass", "src", "sass.snapshot"]), snapshot_path)
+
+      {:unix, :darwin} ->
+        File.cp!(Path.join([tmp_dir, "dart-sass", "src", "dart"]), vm_path)
+        File.cp!(Path.join([tmp_dir, "dart-sass", "src", "sass.snapshot"]), snapshot_path)
+
+      _ ->
+        File.cp!(Path.join([tmp_dir, "dart-sass", "sass"]), bin_path)
+    end
+  end
+
+  # Available targets: https://github.com/sass/dart-sass/releases
+  defp target do
+    case :os.type() do
+      {:win32, _} ->
+        "windows-#{:erlang.system_info(:wordsize) * 8}.zip"
+
+      {:unix, osname} ->
+        arch_str = :erlang.system_info(:system_architecture)
+        [arch | _] = arch_str |> List.to_string() |> String.split("-")
+        osname = if osname == :darwin, do: :macos, else: osname
+
+        case arch do
+          "x86_64" -> "#{osname}-x64.tar.gz"
+          _ -> raise "could not download dart_sass for architecture: #{arch_str}"
+        end
+    end
+  end
+
+  defp fetch_body!(url) do
+    url = String.to_charlist(url)
+    Logger.debug("Downloading dart-sass from #{url}")
+
+    {:ok, _} = Application.ensure_all_started(:inets)
+    {:ok, _} = Application.ensure_all_started(:ssl)
+
+    # https://erlef.github.io/security-wg/secure_coding_and_deployment_hardening/inets
+    cacertfile = CAStore.file_path() |> String.to_charlist()
+
+    http_options = [
+      ssl: [
+        verify: :verify_peer,
+        cacertfile: cacertfile,
+        depth: 2,
+        customize_hostname_check: [
+          match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
+        ]
+      ]
+    ]
+
+    options = [body_format: :binary]
+
+    case :httpc.request(:get, {url, []}, http_options, options) do
+      {:ok, {{_, 200, _}, _headers, body}} ->
+        body
+
+      other ->
+        raise "couldn't fetch #{url}: #{inspect(other)}"
+    end
+  end
+end
diff --git a/lib/esbuild.ex b/lib/esbuild.ex
deleted file mode 100644
index 7edf2ff..0000000
--- a/lib/esbuild.ex
+++ /dev/null
@@ -1,228 +0,0 @@
-defmodule Esbuild do
-  @moduledoc """
-  Esbuild is a installer and runner for [esbuild](https://github.com/evanw/esbuild/).
-
-  ## Profiles
-
-  You can define multiple esbuild profiles. By default, there is a
-  profile called `:default` which you can configure its args, current
-  directory and environment:
-
-      config :esbuild,
-        version: "0.12.15",
-        default: [
-          args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
-          cd: Path.expand("../assets", __DIR__),
-          env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
-        ]
-  """
-
-  use Application
-  require Logger
-
-  @doc false
-  def start(_, _) do
-    unless Application.get_env(:esbuild, :version) do
-      Logger.warn("""
-      esbuild version is not configured. Please set it in your config files:
-
-          config :esbuild, :version, "#{latest_version()}"
-      """)
-    end
-
-    configured_version = configured_version()
-
-    case bin_version() do
-      {:ok, ^configured_version} ->
-        :ok
-
-      {:ok, version} ->
-        Logger.warn("""
-        Outdated esbuild version. Expected #{configured_version}, got #{version}. \
-        Please run `mix esbuild.install` or update the version in your config files.\
-        """)
-
-      :error ->
-        :ok
-    end
-
-    Supervisor.start_link([], strategy: :one_for_one)
-  end
-
-  @doc false
-  # Latest known version at the time of publishing.
-  def latest_version do
-    "0.12.15"
-  end
-
-  @doc """
-  Returns the configured esbuild version.
-  """
-  def configured_version do
-    Application.get_env(:esbuild, :version, latest_version())
-  end
-
-  @doc """
-  Returns the configuration for the given profile.
-
-  Returns nil if the profile does not exist.
-  """
-  def config_for!(profile) when is_atom(profile) do
-    Application.get_env(:esbuild, profile) ||
-      raise ArgumentError, """
-      unknown esbuild profile. Make sure the profile is defined in your config files, such as:
-
-          config :esbuild,
-            #{profile}: [
-              args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
-              cd: Path.expand("../assets", __DIR__),
-              env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
-            ]
-      """
-  end
-
-  @doc """
-  Returns the path to the executable.
-
-  The executable may not be available if it was not yet installed.
-  """
-  def bin_path do
-    Path.join(Path.dirname(Mix.Project.build_path()), "esbuild")
-  end
-
-  @doc """
-  Returns the version of the esbuild executable.
-
-  Returns `{:ok, version_string}` on success or `:error` when the executable
-  is not available.
-  """
-  def bin_version do
-    path = bin_path()
-
-    with true <- File.exists?(path),
-         {result, 0} <- System.cmd(path, ["--version"]) do
-      {:ok, String.trim(result)}
-    else
-      _ -> :error
-    end
-  end
-
-  @doc """
-  Runs the given command with `args`.
-
-  The given args will be appended to the configured args.
-  The task output will be streamed directly to stdio. It
-  returns the status of the underlying call.
-  """
-  def run(profile, extra_args) when is_atom(profile) and is_list(extra_args) do
-    config = config_for!(profile)
-    args = config[:args] || []
-
-    opts = [
-      cd: config[:cd] || File.cwd!(),
-      env: config[:env] || %{},
-      into: IO.stream(:stdio, :line),
-      stderr_to_stdout: true
-    ]
-
-    bin_path()
-    |> System.cmd(args ++ extra_args, opts)
-    |> elem(1)
-  end
-
-  @doc """
-  Installs, if not available, and then runs `esbuild`.
-
-  Returns the same as `run/2`.
-  """
-  def install_and_run(profile, args) do
-    bin_path = Esbuild.bin_path()
-
-    unless File.exists?(bin_path) do
-      install()
-    end
-
-    run(profile, args)
-  end
-
-  @doc """
-  Installs esbuild with `configured_version/0`.
-  """
-  def install do
-    version = Esbuild.configured_version()
-    tmp_dir = Path.join(System.tmp_dir!(), "phx-esbuild")
-    File.rm_rf!(tmp_dir)
-    File.mkdir_p!(tmp_dir)
-
-    name = "esbuild-#{target()}"
-    url = "https://registry.npmjs.org/#{name}/-/#{name}-#{version}.tgz"
-    tar = fetch_body!(url)
-
-    case :erl_tar.extract({:binary, tar}, [:compressed, cwd: tmp_dir]) do
-      :ok -> :ok
-      other -> raise "couldn't unpack archive: #{inspect(other)}"
-    end
-
-    bin_path = Esbuild.bin_path()
-
-    case :os.type() do
-      {:win32, _} ->
-        File.cp!(Path.join([tmp_dir, "package", "esbuild.exe"]), bin_path)
-
-      _ ->
-        File.cp!(Path.join([tmp_dir, "package", "bin", "esbuild"]), bin_path)
-    end
-  end
-
-  # Available targets: https://github.com/evanw/esbuild/tree/master/npm
-  defp target do
-    case :os.type() do
-      {:win32, _} ->
-        "windows-#{:erlang.system_info(:wordsize) * 8}"
-
-      {:unix, osname} ->
-        arch_str = :erlang.system_info(:system_architecture)
-        [arch | _] = arch_str |> List.to_string() |> String.split("-")
-
-        case arch do
-          "x86_64" -> "#{osname}-64"
-          "aarch64" -> "#{osname}-arm64"
-          # TODO: remove when we require OTP 24
-          "arm" when osname == :darwin -> "darwin-arm64"
-          _ -> raise "could not download esbuild for architecture: #{arch_str}"
-        end
-    end
-  end
-
-  defp fetch_body!(url) do
-    url = String.to_charlist(url)
-    Logger.debug("Downloading esbuild from #{url}")
-
-    {:ok, _} = Application.ensure_all_started(:inets)
-    {:ok, _} = Application.ensure_all_started(:ssl)
-
-    # https://erlef.github.io/security-wg/secure_coding_and_deployment_hardening/inets
-    cacertfile = CAStore.file_path() |> String.to_charlist()
-
-    http_options = [
-      ssl: [
-        verify: :verify_peer,
-        cacertfile: cacertfile,
-        depth: 2,
-        customize_hostname_check: [
-          match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
-        ]
-      ]
-    ]
-
-    options = [body_format: :binary]
-
-    case :httpc.request(:get, {url, []}, http_options, options) do
-      {:ok, {{_, 200, _}, _headers, body}} ->
-        body
-
-      other ->
-        raise "couldn't fetch #{url}: #{inspect(other)}"
-    end
-  end
-end
diff --git a/lib/mix/tasks/esbuild.ex b/lib/mix/tasks/esbuild.ex
deleted file mode 100644
index 2019f01..0000000
--- a/lib/mix/tasks/esbuild.ex
+++ /dev/null
@@ -1,43 +0,0 @@
-defmodule Mix.Tasks.Esbuild do
-  @moduledoc """
-  Invokes esbuild with the given args.
-
-  Usage:
-
-  ```bash
-  $ mix esbuild CONTEXT ARGS
-  ```
-
-  Example:
-
-  ```bash
-  $ mix esbuild default assets/js/app.js --bundle --minify --target=es2016 --outdir=priv/static/assets
-  ```
-
-  If esbuild is not installed, it is automatically downloaded.
-  Note the arguments given to this task will be appended
-  to any configured arguments.
-  """
-
-  @shortdoc "Invokes esbuild with the profile and args"
-
-  use Mix.Task
-
-  @impl true
-  def run([profile | args] = all) do
-    if Code.ensure_loaded?(Mix.Tasks.App.Config) do
-      Mix.Task.run("app.config")
-    end
-
-    case Esbuild.install_and_run(String.to_atom(profile), args) do
-      0 -> :ok
-      status -> Mix.raise("`mix esbuild #{Enum.join(all, " ")}` exited with #{status}")
-    end
-
-    Mix.Task.reenable("esbuild")
-  end
-
-  def run([]) do
-    Mix.raise("`mix esbuild` expects the profile as argument")
-  end
-end
diff --git a/lib/mix/tasks/esbuild.install.ex b/lib/mix/tasks/esbuild.install.ex
deleted file mode 100644
index bb58ed1..0000000
--- a/lib/mix/tasks/esbuild.install.ex
+++ /dev/null
@@ -1,45 +0,0 @@
-defmodule Mix.Tasks.Esbuild.Install do
-  @moduledoc """
-  Installs esbuild under `_build`.
-
-  ```bash
-  $ mix esbuild.install
-  $ mix esbuild.install --if-missing
-  ```
-
-  By default, it installs #{Esbuild.latest_version()} but you
-  can configure it in your config files, such as:
-
-      config :esbuild, :version, "#{Esbuild.latest_version()}"
-
-  You can pass the `--if-missing` flag to only install it if
-  one does not yet exist.
-  """
-
-  @shortdoc "Installs esbuild under _build"
-  use Mix.Task
-
-  @impl true
-  def run(args) do
-    case OptionParser.parse_head!(args, strict: [if_missing: :boolean]) do
-      {opts, []} ->
-        if opts[:if_missing] && File.exists?(Esbuild.bin_path()) do
-          :ok
-        else
-          if Code.ensure_loaded?(Mix.Tasks.App.Config) do
-            Mix.Task.run("app.config")
-          end
-
-          Esbuild.install()
-        end
-
-      {_, _} ->
-        Mix.raise("""
-        Invalid arguments to esbuild.install, expected one of:
-
-            mix esbuild.install
-            mix esbuild.install --if-missing
-        """)
-    end
-  end
-end
diff --git a/lib/mix/tasks/sass.ex b/lib/mix/tasks/sass.ex
new file mode 100644
index 0000000..9cfcda8
--- /dev/null
+++ b/lib/mix/tasks/sass.ex
@@ -0,0 +1,43 @@
+defmodule Mix.Tasks.Sass do
+  @moduledoc """
+  Invokes sass with the given args.
+
+  Usage:
+
+  ```bash
+  $ mix sass CONTEXT ARGS
+  ```
+
+  Example:
+
+  ```bash
+  $ mix sass default assets/css/app.scss priv/static/assets/app.css
+  ```
+
+  If dart-sass is not installed, it is automatically downloaded.
+  Note the arguments given to this task will be appended
+  to any configured arguments.
+  """
+
+  @shortdoc "Invokes sass with the profile and args"
+
+  use Mix.Task
+
+  @impl true
+  def run([profile | args] = all) do
+    if Code.ensure_loaded?(Mix.Tasks.App.Config) do
+      Mix.Task.run("app.config")
+    end
+
+    case DartSass.install_and_run(String.to_atom(profile), args) do
+      0 -> :ok
+      status -> Mix.raise("`mix sass #{Enum.join(all, " ")}` exited with #{status}")
+    end
+
+    Mix.Task.reenable("sass")
+  end
+
+  def run([]) do
+    Mix.raise("`mix sass` expects the profile as argument")
+  end
+end
diff --git a/lib/mix/tasks/sass.install.ex b/lib/mix/tasks/sass.install.ex
new file mode 100644
index 0000000..6de5950
--- /dev/null
+++ b/lib/mix/tasks/sass.install.ex
@@ -0,0 +1,45 @@
+defmodule Mix.Tasks.Sass.Install do
+  @moduledoc """
+  Installs dart-sass under `_build`.
+
+  ```bash
+  $ mix sass.install
+  $ mix sass.install --if-missing
+  ```
+
+  By default, it installs #{DartSass.latest_version()} but you
+  can configure it in your config files, such as:
+
+      config :dart_sass, :version, "#{DartSass.latest_version()}"
+
+  You can pass the `--if-missing` flag to only install it if
+  one does not yet exist.
+  """
+
+  @shortdoc "Installs dart-sass under _build"
+  use Mix.Task
+
+  @impl true
+  def run(args) do
+    case OptionParser.parse_head!(args, strict: [if_missing: :boolean]) do
+      {opts, []} ->
+        if opts[:if_missing] && File.exists?(DartSass.bin_path()) do
+          :ok
+        else
+          if Code.ensure_loaded?(Mix.Tasks.App.Config) do
+            Mix.Task.run("app.config")
+          end
+
+          DartSass.install()
+        end
+
+      {_, _} ->
+        Mix.raise("""
+        Invalid arguments to sass.install, expected one of:
+
+            mix sass.install
+            mix sass.install --if-missing
+        """)
+    end
+  end
+end
diff --git a/mix.exs b/mix.exs
index 00b8688..e0f1a95 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,25 +1,25 @@
-defmodule Esbuild.MixProject do
+defmodule DartSass.MixProject do
   use Mix.Project
 
   @version "0.1.3"
-  @source_url "https://github.com/phoenixframework/esbuild"
+  @source_url "https://github.com/CargoSense/dart_sass"
 
   def project do
     [
-      app: :esbuild,
+      app: :dart_sass,
       version: @version,
       elixir: "~> 1.9",
       deps: deps(),
-      description: "Mix tasks for installing and invoking esbuild",
+      description: "Mix tasks for installing and invoking sass",
       package: [
         links: %{
           "GitHub" => @source_url,
-          "esbuild" => "https://esbuild.github.io"
+          "dart-sass" => "https://sass-lang.com/dart-sass"
         },
         licenses: ["MIT"]
       ],
       docs: [
-        main: "Esbuild",
+        main: "DartSass",
         source_url: @source_url,
         source_ref: "v#{@version}",
         extras: ["CHANGELOG.md"]
@@ -27,7 +27,7 @@ defmodule Esbuild.MixProject do
       xref: [
         exclude: [:httpc, :public_key]
       ],
-      aliases: [test: ["esbuild.install --if-missing", "test"]]
+      aliases: [test: ["sass.install --if-missing", "test"]]
     ]
   end
 
@@ -35,7 +35,7 @@ defmodule Esbuild.MixProject do
     [
       # inets/ssl may be used by Mix tasks but we should not impose them.
       extra_applications: [:logger],
-      mod: {Esbuild, []},
+      mod: {DartSass, []},
       env: [default: []]
     ]
   end
diff --git a/test/dart_sass_test.exs b/test/dart_sass_test.exs
new file mode 100644
index 0000000..200016a
--- /dev/null
+++ b/test/dart_sass_test.exs
@@ -0,0 +1,15 @@
+defmodule DartSassTest do
+  use ExUnit.Case, async: true
+
+  test "run on default" do
+    assert ExUnit.CaptureIO.capture_io(fn ->
+             assert DartSass.run(:default, ["--version"]) == 0
+           end) =~ "1.36.0"
+  end
+
+  test "run on profile" do
+    assert ExUnit.CaptureIO.capture_io(fn ->
+             assert DartSass.run(:another, []) == 0
+           end) =~ "1.36.0"
+  end
+end
diff --git a/test/esbuild_test.exs b/test/esbuild_test.exs
deleted file mode 100644
index b3d6b19..0000000
--- a/test/esbuild_test.exs
+++ /dev/null
@@ -1,15 +0,0 @@
-defmodule EsbuildTest do
-  use ExUnit.Case, async: true
-
-  test "run on default" do
-    assert ExUnit.CaptureIO.capture_io(fn ->
-             assert Esbuild.run(:default, ["--version"]) == 0
-           end) =~ "0.12.15"
-  end
-
-  test "run on profile" do
-    assert ExUnit.CaptureIO.capture_io(fn ->
-             assert Esbuild.run(:another, []) == 0
-           end) =~ "0.12.15"
-  end
-end