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
経緯
- gemのqiita_markdownを入れた(https://github.com/increments/qiita-markdown)
- 四苦八苦しながらcmakeをインストール
- bundle install(通った)
-
rails assets:precompile
失敗(下記ご参照)
$ 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