dartsass-rails 0.3.0 → 0.4.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: 2bb5dbbe961c634d409fb2970b7f38bdc3ada499464fbd3f6b08e7611912601a
4
- data.tar.gz: 37d5f1fedc4776681e06f644d78e1ec0535d4d64f7cd69bc94ad268fcdb35d88
3
+ metadata.gz: 165bcaadffc761840fcd9a39e1b2f6f862974e62b22dab5e6841d485dc94d072
4
+ data.tar.gz: 6629e2d3f46c0a2787fc8af5ba25298f613f5817b3e237c988958ef8d57f2aca
5
5
  SHA512:
6
- metadata.gz: c7dd747bdab7faf6c76ec493d0dc31ea328a7841710402d6d2570fc078903417eb57be0d29e97cbf3018d84723acbdf68f31a2abf1cf6ca606e9de09a690e11c
7
- data.tar.gz: a388121bf37cd4e00928b7b47425bc782b61d46fd9f422f7bda9abadb874527ca6eaf59ade8514e3247b156b719ea7e10dc0b5cc3baae297a5e34ad3cd060f72
6
+ metadata.gz: d5dceba364d547b14f80da2eebf9b55c7b402b911ffa242ccab950b1c54425ca334d5b42916903ea82fa7f0536f1150a6931c8a9c727ef92b05ce2b2dd0b20c1
7
+ data.tar.gz: 352ac02425d2b164d506c36496d19ea016e423e0c01c2bcf4b0e0474fb5c6aad261994be84c1a880b3079694219bcea1c77e932fa1a9caa32ca682700b64171c
data/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [Sass](https://sass-lang.com) is a stylesheet language that’s compiled to CSS. It allows you to use variables, nested rules, mixins, functions, and more, all with a fully CSS-compatible syntax.
4
4
 
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.
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 (Intel, Apple Silicon), Linux (x86-64, AArch64), and Windows (x86-64).
6
6
 
7
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
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
- 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.
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 start both the Dart Sass watch process and the rails server in development mode.
12
12
 
13
13
 
14
14
  ## Installation
@@ -16,7 +16,6 @@ When you're developing your application, you want to run Dart Sass in watch mode
16
16
  1. Run `./bin/bundle add dartsass-rails`
17
17
  2. Run `./bin/rails dartsass:install`
18
18
 
19
-
20
19
  ## Building in production
21
20
 
22
21
  The `dartsass:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Dart Sass output will be generated.
@@ -26,7 +25,7 @@ The `dartsass:build` is automatically attached to `assets:precompile`, so before
26
25
  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
26
 
28
27
 
29
- ```
28
+ ```ruby
30
29
  # config/initializers/dartsass.rb
31
30
  Rails.application.config.dartsass.builds = {
32
31
  "app/index.sass" => "app.css",
@@ -36,9 +35,91 @@ Rails.application.config.dartsass.builds = {
36
35
 
37
36
  The hash 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
37
 
38
+ ## Configuring build options
39
+
40
+ By default, sass is invoked with `--style=compressed --no-source-map`. You can adjust these options by overwriting `Rails.application.config.dartsass.build_options`.
41
+
42
+ ```ruby
43
+ # config/initializers/dartsass.rb
44
+ Rails.application.config.dartsass.build_options << " --quiet-deps"
45
+ ```
46
+
39
47
  ## Importing assets from gems
40
48
  `dartsass:build` includes application [assets paths](https://guides.rubyonrails.org/asset_pipeline.html#search-paths) as Sass [load paths](https://sass-lang.com/documentation/at-rules/use#load-paths). Assuming the gem has made assets visible to the Rails application, no additional configuration is required to use them.
41
49
 
50
+ ## Migrating from sass-rails
51
+
52
+ If you're migrating from [sass-rails](https://github.com/rails/sass-rails)
53
+ (applies to [sassc-rails](https://github.com/sass/sassc-rails) as well)
54
+ and want to switch to dartsass-rails, follow these instructions below:
55
+
56
+ 1. Remove the sass-rails gem from the Gemfile by running
57
+
58
+ ```
59
+ ./bin/bundle remove sass-rails
60
+ ```
61
+
62
+ 1. Install dartsass-rails by following the
63
+ [Installation](#installation) instructions above
64
+
65
+ 1. Remove any references to Sass files from the Sprockets manifest file:
66
+ `app/assets/config/manifest.js`
67
+
68
+ 1. In your continuous integration pipeline, before running any tests that
69
+ interact with the browser, make sure to build the Sass files by running:
70
+
71
+ ```
72
+ bundle exec rails dartsass:build
73
+ ```
74
+
75
+ ## Troubleshooting
76
+
77
+ Some common problems experienced by users:
78
+
79
+ ### LoadError: cannot load such file -- sassc
80
+
81
+ The reason for the above error is that Sprockets is trying to build Sass files
82
+ but the sass-rails or sassc-rails gems are not installed. This is expected,
83
+ since Dart Sass is used instead to build Sass files, and the solution is
84
+ to make sure that Sprockets is not building any Sass files.
85
+
86
+ There are three reasons why this error can occur:
87
+
88
+ #### Sass files are referenced in the Sprockets manifest file
89
+
90
+ If any Sass files are referenced in the Sprockets manifest file
91
+ (`app/assets/config/manifest.js`) Sprockets will try to build the Sass files and
92
+ fail.
93
+
94
+ ##### Solution
95
+
96
+ Remove any references to Sass files from the Sprockets manifest file. These are
97
+ now handled by Dart Sass. If you have more Sass files than `application.scss`,
98
+ make sure these are compiled by Dart Sass
99
+ (see [Configuring builds](#configuring-builds) above).
100
+
101
+ #### Running locally
102
+
103
+ If you receive this error when running the Rails server locally and have
104
+ already removed any references to Sass files from the Sprockets manifest file,
105
+ the Dart Sass process is most likely not running.
106
+
107
+ ##### Solution
108
+
109
+ Make sure the Dart Sass process is running by starting the Rails sever by
110
+ running: `./bin/dev`.
111
+
112
+ #### Running continuous integration pipelines
113
+
114
+ If you receive this error when running tests that interact with the browser in
115
+ a continuous integration pipeline and have removed any references to Sass files
116
+ from the Sprockets manifest file, the Sass files have most likely not been
117
+ built.
118
+
119
+ ##### Solution
120
+
121
+ Add a step to the continuous integration pipeline to build the Sass files with
122
+ the following command: `bundle exec rails dartsass:build`.
42
123
 
43
124
  ## Version
44
125
 
data/exe/dartsass CHANGED
@@ -2,17 +2,18 @@
2
2
  # because rubygems shims assume a gem's executables are Ruby
3
3
 
4
4
  require "shellwords"
5
+ require "rbconfig"
5
6
 
6
- platform_info = Gem::Platform.local
7
- platform_string = "#{platform_info.cpu}-#{platform_info.os}"
7
+ system_config = RbConfig::CONFIG
8
+ platform_string = "#{system_config["host_cpu"]}-#{system_config["host_os"]}"
8
9
 
9
- exe_path =
10
+ exe_path =
10
11
  case platform_string
11
- when "aarch64-linux" then File.join(__dir__, "aarch64-linux/sass")
12
- when "arm64-darwin" then File.join(__dir__, "arm64-darwin/sass")
13
- when /darwin\z/ then File.join(__dir__, "darwin/sass")
14
- when /linux\z/ then File.join(__dir__, "linux/sass")
15
- when /mingw32\z/ then File.join(__dir__, "mingw32/sass.bat")
12
+ when /aarch64-linux/ then File.join(__dir__, "aarch64-linux/sass")
13
+ when /arm64-darwin/ then File.join(__dir__, "arm64-darwin/sass")
14
+ when /darwin/ then File.join(__dir__, "darwin/sass")
15
+ when /linux/ then File.join(__dir__, "linux/sass")
16
+ when /mswin|mingw|cygwin/ then File.join(__dir__, "mingw32/sass.bat")
16
17
  else
17
18
  STDERR.puts(<<~ERRMSG)
18
19
  ERROR: dartsass-rails does not support the #{platform_string} platform
@@ -4,5 +4,6 @@ module Dartsass
4
4
  class Engine < ::Rails::Engine
5
5
  config.dartsass = ActiveSupport::OrderedOptions.new
6
6
  config.dartsass.builds = { "application.scss" => "application.css" }
7
+ config.dartsass.build_options = "--style=compressed --no-source-map"
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module Dartsass
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/tasks/build.rake CHANGED
@@ -9,7 +9,7 @@ def dartsass_build_mapping
9
9
  end
10
10
 
11
11
  def dartsass_build_options
12
- "--style=compressed --no-source-map"
12
+ Rails.application.config.dartsass.build_options
13
13
  end
14
14
 
15
15
  def dartsass_load_paths
@@ -23,12 +23,12 @@ end
23
23
  namespace :dartsass do
24
24
  desc "Build your Dart Sass CSS"
25
25
  task build: :environment do
26
- system dartsass_compile_command
26
+ system dartsass_compile_command, exception: true
27
27
  end
28
28
 
29
29
  desc "Watch and build your Dart Sass CSS on file changes"
30
30
  task watch: :environment do
31
- system "#{dartsass_compile_command} -w"
31
+ system "#{dartsass_compile_command} -w", exception: true
32
32
  end
33
33
  end
34
34
 
@@ -1,6 +1,6 @@
1
1
  namespace :dartsass do
2
2
  desc "Install Dart Sass into the app"
3
3
  task :install do
4
- system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/dartsass.rb", __dir__)}"
4
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/dartsass.rb", __dir__)}", exception: true
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dartsass-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-19 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.2.32
82
+ rubygems_version: 3.3.14
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Integrate Dart Sass with the asset pipeline in Rails.