やりたいこと
rails アプリをherokuでデプロイしたい
##エラー
error: failed to push some refs to 'https://git.heroku.com/cryptic-everglades-97405.git'
でデプロイされない
ターミナル Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true). 省略 remote: 2299 remote: 2300 remote: 2301 remote: 2302 remote: => const nav = document.getElementsByClassName("nav-js")[0]; remote: 2304 const button = document.getElementsByClassName("js-nav-button")[0]; remote: 2305 remote: 2306 button.addEventListener("click", () => { remote: 2307 nav.classList.toggle("active"); remote: 2308 remote: 2309 if (nav.classList.contains("active")) { remote: 2310 button.classList.add("active"); remote: 2311 } else { remote: == 省略 remote: ! remote: ! Precompiling assets failed. remote: ! 省略 To https://git.heroku.com/cryptic-everglades-97405.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/cryptic-everglades-97405.git'
=> const nav = document.getElementsByClassName("nav-js")[0];
が赤くなっている
application.js // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's // vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require rails-ujs //= require activestorage //= require_tree . const nav = document.getElementsByClassName("nav-js")[0]; const button = document.getElementsByClassName("js-nav-button")[0]; button.addEventListener("click", () => { nav.classList.toggle("active"); if (nav.classList.contains("active")) { button.classList.add("active"); } else { button.classList.remove("active"); } });
config/environments/production.rb config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = Uglifier.new(harmony: true) # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = true
## 試したこと
Uglifier.new(harmony: true)と記述したが、エラーが発生し、なにが間違っているのかがわからない
あなたの回答
tips
プレビュー