问题
Cssbundling-rails仅在容器启动时在Apple M1 macbook上的Docker容器内编译。对指定的监视scss文件进行后续更改不会触发重新编译。Docker容器正在使用Colima运行。
详细说明
设置使用Foreman和procfile来处理cssbundling-rails和jsbundling-rails的监视器。bin/dev在docker-compose文件中执行。javascript捆绑正在按预期监视和重新编译application.js。
使用以下命令设置Colima上下文colima start --arch x86_64 --cpu 4 --memory 6 --disk
docker context use colima
以下命令在docker容器中成功运行:rails css:install:bootstrap
MacBook正在运行MacOS Monterey版本12.6
Package.json包含以下脚本
"scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=assets",
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}
当对/app/assets/stylesheets/application.bootstrap.scss
进行任何更改时,不会重新编译任何内容。拆下docker容器然后重新启动它会导致css被重新编译。终端中未列出故障。
以下是重新启动的容器的输出$ sass ./app/assets/stylesheets/application.bootstrap.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules --watch
$ Sass is watching for changes. Press Ctrl-C to stop
Gemfile
source "https://rubygems.org"
ruby "3.1.3"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.4", ">= 7.0.4.3"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use sqlserver as the database for Active Record
gem "activerecord-sqlserver-adapter"
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
#gem "importmap-rails"
gem "tiny_tds"
gem "jsbundling-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
gem "cssbundling-rails"
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "rspec-rails"
gem "factory_bot_rails"
gem "faker"
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
end
1条答案
按热度按时间tpgth1q71#
更新到MacOS 13 Ventura并在Docker Desktop中启用“使用虚拟化框架”,使css捆绑能够按预期工作。
/app/assets/stylesheets/application.bootstrap.scss
文件中的更改会导致监视器触发重新编译css。Docker关于新虚拟化框架的文档