kakudaisuke
@kakudaisuke (daisuke kaku)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Amazon Lightsail(EC2)でrails assets:precompileがCompilation failed、そしてEverything's up-to-date. Nothing to do...

解決したいこと

Railsでアプリを作っていて、Amazon Lightsailインスタンス(EC2)にデプロイしています。

EC2上でrails assets:precompileをしてもCompilation failed:となり、ローカルで行ったCSSの修正をデプロイしても反映されなくなってしまいました...

以下のような感じです。

[ec2-user@ip-... minnfra]$ rails assets:precompile RAILS_ENV=staging
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.34s.
Compiling...
Compilation failed:

[ec2-user@ip-... minnfra]$

minnfraというのは私のアプリ名です。
ちなみに再度やると、Everything's up-to-date. Nothing to doと言われてしまいます。

[ec2-user@ip-... minnfra]$ rails assets:precompile RAILS_ENV=staging
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.04s.
Everything's up-to-date. Nothing to do

経緯

$ rails assets:precompile RAILS_ENV=staging
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.23s.
Compiling...
Compilation failed:
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
    ["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
  • 上記エラーに従ってnpx browserslist@latest --update-db実行
  • Browserslist: caniuse-lite is outdatedは消えたがbabelのwarningがめっちゃ出る
  • そういえばこれ入れてなかったとgem 'github-linguist'追加、bundle install。bundleは無事終わるがrails assets:precompileのbabelのwarningが前回よりだいぶ減ったものの出続ける(下記ご参照)
[ec2-user@ip-... minnfra]$ rails assets:precompile RAILS_ENV=staging
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.10s.
Compiling...
Compilation failed:
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
	["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
to the "plugins" section of your Babel config.
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-property-in-object.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
	["@babel/plugin-proposal-private-methods", { "loose": true }]
to the "plugins" section of your Babel config.
  • babel.config.jsに対策を追記
  • 具体的なエラー内容もなくCompilation failed:だけ出るようになる...

その他自分で試したこと

ググって見つけた記事の内容を試してみました。

WEBPACKER_PRECOMPILE=falseを付け加える

[ec2-user@ip-... minnfra]$ WEBPACKER_PRECOMPILE=false bundle exec rails assets:precompile RAILS_ENV=staging
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.62s.

assets:precompile:allそんなものは無さそう...

[ec2-user@ip-... minnfra]$ rails assets:precompile:all RAILS_ENV=staging
rails aborted!
Don't know how to build task 'assets:precompile:all' (See the list of available tasks with `rails --tasks`)
Did you mean?  assets:precompile
/var/www/minnfra/bin/rails:11:in `<top (required)>'
/var/www/minnfra/bin/spring:16:in `<top (required)>'
(See full trace by running task with --trace)

環境、ソースコード

インスタンス情報
Amazon Linux 2
2 GB RAM、1 vCPU、60 GB のSSD
Gemfile
gem 'qiita-markdown'
gem 'github-linguist'
babel.config.js
module.exports = function(api) {
  省略

  return {
    presets: [
      省略
    ].filter(Boolean),
    plugins: [
      省略
      // 以下追加
      [
        "@babel/plugin-proposal-private-property-in-object",
        { "loose": true }
      ],
      [
        "@babel/plugin-proposal-private-methods",
        { "loose": true }
      ]
    ].filter(Boolean)
  }
}

お力添えいただけると、とてもありがたいです。
よろしくお願いします!

0

No Answers yet.

Your answer might help someone💌