1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dart Sass for Railsのビルドオプションの設定方法

Last updated at Posted at 2024-03-24

Dart Sass for Railsのビルドオプションの設定方法ですが

公式ドキュメントには以下のように記載されています。

Configuring build options

By default, sass is invoked with ["--style=compressed", "--no-source-map"]. You can adjust these options by overwriting Rails.application.config.dartsass.build_options.

config/initializers/dartsass.rb
# config/initializers/dartsass.rb
Rails.application.config.dartsass.build_options << "--no-charset" << "--quiet-deps"

ところが以下のようにエラーが出ます

$ bundle exec rails dartsass:build
Could not find an option named "no-source-map--no-source-map--no-error-css".

コードを観た感じ配列ではなく文字列を想定しているようです。

dartsass-rails-0.5.0/lib/tasks/build.rake
# :
def dartsass_build_options
  puts "dartsass_build_options: #{Rails.application.config.dartsass.build_options}"
  Rails.application.config.dartsass.build_options
end
# :
def dartsass_compile_command
   "#{EXEC_PATH} #{dartsass_build_options} #{dartsass_load_paths} #{dartsass_build_mapping}"
end
# :
namespace :dartsass do
  desc "Build your Dart Sass CSS"
  task build: :environment do
    system dartsass_compile_command, exception: true
  end
  # :
end
# :

正解

config/initializers/dartsass.rb
# config/initializers/dartsass.rb
Rails.application.config.dartsass.build_options = "--no-source-map --no-error-css"
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?