dartsass-rails 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 926726f873ae7ec4d5b024cfad0dc452c290baa35842100bd98c74bb13d91eea
4
- data.tar.gz: 65e0520536f1b0649f1394386df0dde7a0f4774155b7a689e04e514e96e3de81
3
+ metadata.gz: 66fafe0b069b2b52d2bea2dacd17eba808087e97edd7f64453ba40461afa5a69
4
+ data.tar.gz: c387c8b7adb29211b6993485ae19b3f58d8cdfb6a75eed8bd1139d1d51a486f6
5
5
  SHA512:
6
- metadata.gz: 22ab26793030f9679e5e130567322e999027df10275e922de89f3ffc9ce2976e5dfae6d9b1a8db7c03cf92cd2bd044867e0d30c73fbe1337f45d1d1afba5f92e
7
- data.tar.gz: 3d5c7241ad28f38147543e8dda20f49abc49fbe1361206fb19a1381861a3581701eb3004ced39dd7449bd3082d8d6c1d7a1fbe51aec4d55194ac39ddb44bb93b
6
+ metadata.gz: 58dc3c83d2b3754aad2d774ddb3f10f6b78d9e907097b61ed466d3b2734e6b4d492b192e7dee83443b705459a3560a38c8b44c652e1e0f4592ae7873cdac8f1a
7
+ data.tar.gz: 7fed1df3503131583f165553a9b9dd2de454b8c4fb324f19854a89e85e9b1e1ff7fc665e31095b5caf51effe782ea4fd6d872740ccd25aabac0ea1b33f7faf4b
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  This gem wraps [the standalone executable version](https://github.com/sass/dart-sass/releases) of the Dart version of Sass. These executables are platform specific, but included in this gem are the ones for macOS, Linux, and Windows. The Linux and Windows versions are the ones for 64-bit, and the macOS version is compiled for Intel but will run on ARM as well.
6
6
 
7
- The installer will create your Sass input file in `app/assets/stylesheets/application.scss`. This is where you should import all the style files to be compiled [using the @use rule](https://sass-lang.com/documentation/at-rules/use). When you run `rails dartsass:build`, this input file will be used to generate the output in `app/assets/builds/application.css`. That's the output CSS that you'll include in your app.
7
+ The installer will create your default Sass input file in `app/assets/stylesheets/application.scss`. This is where you should import all the style files to be compiled [using the @use rule](https://sass-lang.com/documentation/at-rules/use). When you run `rails dartsass:build`, this input file will be used to generate the output in `app/assets/builds/application.css`. That's the output CSS that you'll include in your app. The load path for Sass is automatically configured to be `app/assets/stylesheets`.
8
8
 
9
- If you need to use a custom input or output file, you can run `bundle exec dartsass` to access the platform-specific executable, and give it your own build options.
9
+ If you need to configure the build process beyond configuring the build files – you can run `bundle exec dartsass` to access the platform-specific executable, and give it your own build options.
10
10
 
11
11
  When you're developing your application, you want to run Dart Sass in watch mode, so changes are automatically reflected in the generated CSS output. You can do this either by running `rails dartsass:watch` as a separate process, or by running `./bin/dev` which uses [foreman](https://github.com/ddollar/foreman) to starts both the Dart Sass watch process and the rails server in development mode.
12
12
 
@@ -21,6 +21,21 @@ When you're developing your application, you want to run Dart Sass in watch mode
21
21
 
22
22
  The `dartsass:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Dart Sass output will be generated.
23
23
 
24
+ ## Configuring builds
25
+
26
+ By default, only `app/assets/stylesheets/application.scss` will be built. If you'd like to change the path of this stylesheet, add additional entry points, or customize the name of the built file, use the `Rails.application.config.dartsass.builds` configuration hash.
27
+
28
+
29
+ ```
30
+ # config/initializers/dartsass.rb
31
+ Rails.application.config.dartsass.builds = {
32
+ "app/index.sass" => "app.css",
33
+ "site.scss" => "site.css"
34
+ }
35
+ ```
36
+
37
+ The has key is the relative path to a Sass file in `app/assets/stylesheets/` and the hash value will be the name of the file output to `app/assets/builds/`.
38
+
24
39
 
25
40
  ## Version
26
41
 
@@ -2,5 +2,7 @@ require "rails"
2
2
 
3
3
  module Dartsass
4
4
  class Engine < ::Rails::Engine
5
+ config.dartsass = ActiveSupport::OrderedOptions.new
6
+ config.dartsass.builds = { "application.scss" => "application.css" }
5
7
  end
6
8
  end
@@ -1,3 +1,3 @@
1
1
  module Dartsass
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/tasks/build.rake CHANGED
@@ -1,14 +1,30 @@
1
- DARTSASS_COMPILE_COMMAND = "#{Pathname.new(__dir__).to_s}/../../exe/dartsass #{Rails.root.join("app/assets/stylesheets/application.scss")} #{Rails.root.join("app/assets/builds/application.scss")}"
1
+ EXEC_PATH = "#{Pathname.new(__dir__).to_s}/../../exe/dartsass"
2
+ CSS_LOAD_PATH = Rails.root.join("app/assets/stylesheets")
3
+ CSS_BUILD_PATH = Rails.root.join("app/assets/builds")
4
+
5
+ def dartsass_build_mapping
6
+ Rails.application.config.dartsass.builds.map { |input, output|
7
+ "#{CSS_LOAD_PATH.join(input)}:#{CSS_BUILD_PATH.join(output)}"
8
+ }.join(" ")
9
+ end
10
+
11
+ def dartsass_load_path
12
+ "--load-path #{CSS_LOAD_PATH}"
13
+ end
14
+
15
+ def dartsass_compile_command
16
+ "#{EXEC_PATH} #{dartsass_load_path} #{dartsass_build_mapping}"
17
+ end
2
18
 
3
19
  namespace :dartsass do
4
20
  desc "Build your Dart Sass CSS"
5
- task :build do
6
- system DARTSASS_COMPILE_COMMAND
21
+ task build: :environment do
22
+ system dartsass_compile_command
7
23
  end
8
24
 
9
25
  desc "Watch and build your Dart Sass CSS on file changes"
10
- task :watch do
11
- system "#{DARTSASS_COMPILE_COMMAND} -w"
26
+ task watch: :environment do
27
+ system "#{dartsass_compile_command} -w"
12
28
  end
13
29
  end
14
30
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dartsass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson