0

Goal is to precompile my assts, js files, I assume.

What I am really doing is wanting to use a .js file in my assets/javascript folder on a specific page when it loads.

My issue is when delpoying to Heroku.

my assets.rb:

Rails.application.config.assets.precompile << '*.js'

Production.rb:

config.assets.js_compressor = Uglifier.new(harmony: true)
config.assets.compile = false

Error:

undefined method `start_with?' for nil:NilClass

Fix: https://github.com/lautis/uglifier/issues/137

  config.assets.js_compressor = Uglifier.new(harmony: true, compress: { unused: false })

This now gives me the Error:

Uglifier::Error: Unexpected token punc «:», expected punc «,» rails

Anyone have these issues with a fix for it?

uno
  • 1,421
  • 12
  • 38
  • Try setting this to false/true: `Rails.application.config.assets.precompile = false`. I don't think that the precompile can accept `<<`. You can just precompile with a rake task in heroku - i think it does this automatically. – BenKoshy Oct 01 '19 at 01:36

1 Answers1

0

Here I found help for the same problem you had.

Run rails console and:

    JS_PATH = "app/assets/javascripts/**/*.js"; 
     Dir[JS_PATH].each do |file_name|
      puts "\n#{file_name}"
      puts Uglifier.compile(File.read(file_name))
    end