5

esbuild使用with 的新 Rails 7 应用程序tailwind

当我运行时rake assets:precompile,我收到此错误:LoadError: cannot load such file -- sassc

由于 SaasC 语法错误,我删除了sassc-railsgem 。

这是本地预编译的完整输出......

rake assets:precompile
yarn install v1.22.15
[1/4]   Resolving packages...
success Already up-to-date.
✨  Done in 0.06s.
yarn run v1.22.15
$ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds

  app/assets/builds/application.js      185.5kb
  app/assets/builds/application.js.map  301.0kb

✨  Done in 0.13s.
yarn install v1.22.15
[1/4]   Resolving packages...
success Already up-to-date.
✨  Done in 0.06s.
yarn run v1.22.15
$ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css

Done in 155ms.
✨  Done in 0.52s.
rake aborted!
LoadError: cannot load such file -- sassc

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

这是 Heroku 的输出......

Running: rake assets:precompile
       yarn install v1.22.17
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       success Saved lockfile.
       Done in 4.39s.
       yarn run v1.22.17
       $ esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds
       
         app/assets/builds/application.js      185.5kb
         app/assets/builds/application.js.map  301.0kb
       
       Done in 0.11s.
       yarn install v1.22.17
       [1/4] Resolving packages...
       success Already up-to-date.
       Done in 0.13s.
       yarn run v1.22.17
       $ tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css
       
       Done in 440ms.
       Done in 0.99s.
       rake aborted!
       LoadError: cannot load such file -- sassc
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/autoload/sassc.rb:2:in `<main>'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:100:in `register'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:42:in `initialize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `new'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:27:in `instance'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/sassc_processor.rb:31:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/base.rb:88:in `find_all_linked_assets'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:19:in `execute'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:363:in `run_task'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `block (3 levels) in create_worker'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `loop'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `block (2 levels) in create_worker'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `catch'
       /tmp/build_7c167d00/vendor/bundle/ruby/3.0.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block in create_worker'
       Tasks: TOP => assets:precompile
       (See full trace by running task with --trace)

不知道还有什么可以在这里尝试的。

4

2 回答 2

1

I had the same issue today and resolved it on the Heroku end by clearing the Heroku build cache (instructions here)

heroku plugins:install heroku-builds

heroku builds:cache:purge -a example-app
于 2021-12-20T21:47:34.337 回答
1

我有同样的问题并通过以下方式解决。

  • app/assets/stylesheets/* 中的所有 .scss 到 .css(如果您已写入@import ....scss 文件,请修复为*= require ...
  • $ bundle clean

就我而言,我猜是因为我在顺风之前使用了引导程序,所以关于引导程序的 .scss 文件一直保留在供应商/捆绑包中。

于 2021-12-24T08:34:12.803 回答