A
A
Anton Misyagin2016-07-19 11:32:34
Ruby on Rails
Anton Misyagin, 2016-07-19 11:32:34

Is it possible to add custom algorithm on top of rails js uglifier?

I have scripts written in coffee. In the process of precompiling resources, they are converted into javascript, comments are removed, minification, gluing, etc. But there is a desire to add your own handiwork to the resulting code. Those. I would like to take the result of uglifier and still make fun of the code. I seem to have met such an opportunity, but then it was not needed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Misyagin, 2016-07-19
@sunnmas

rusrails.ru/asset-pipeline#javascript-coffeescript...
I found where I saw it, but then how to start the standard compressor first, and then your own:
Настройки конфигурации компрессора для CSS и JavaScript также могут принимать любой объект. Этот объект должен иметь метод compress, принимающий строку как единственный аргумент, и он должен возвращать строку.

class Transformer
  def compress(string)
    do_something_returning_a_string(string)
  end
end

Чтобы его включить, передайте new объект в настройку конфигурации в application.rb:
config.assets.css_compressor = Transformer.new

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question