Ошибка предварительной компиляции Rails в производственном режиме - PullRequest
0 голосов
/ 05 октября 2018

Когда я запускаю rake assets: prcompile RAILS_ENV = production, я получаю ошибку ниже. Но если я запускаю в режиме разработки, он работает нормально.

rake assets:precompile RAILS_ENV=production

rake aborted!

Uglifier::Error: fs redeclared

Environment

Rails 5.0.7 Ruby 2.4.1

Может кто-нибудь помочь решить эту проблему

1 Ответ

0 голосов
/ 05 октября 2018

Получил проблему. В моем файле application.js есть следующие коды

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

В соответствии с функциональностью require_tree , он будет рекурсивно включать все js-файлы текущего пути.См. Ссылку https://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives

In JavaScript files, Sprockets directives begin with //=. In the above case, the file is using the require and the require_tree directives. The require directive is used to tell Sprockets the files you wish to require. Here, you are requiring the files rails-ujs.js and turbolinks.js that are available somewhere in the search path for Sprockets. You need not supply the extensions explicitly. Sprockets assumes you are requiring a .js file when done from within a .js file.

The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output. These paths must be specified relative to the manifest file. You can also use the require_directory directive which includes all JavaScript files only in the directory specified, without recursion.

. В моем приложении файл Gruntfile.js был объявлен в двух папках js. Так, когда я выполнял прекомпиляцию, поскольку файл был объявлен в двух js, он выбрасываетошибка при попытке сжать этот файл

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...