mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:51:08 +08:00
DEV: Don't use js.erb
for constants
Adds a new rake task to auto generate a constants.js file with the constants present. This makes migrating to Ember CLI easier, but also slightly speeds up asset compilation by having to do less work. If the constants change you need to run: `rake javascripts:update_constants`
This commit is contained in:
@ -12,8 +12,24 @@ def library_src
|
||||
"#{Rails.root}/node_modules"
|
||||
end
|
||||
|
||||
task 'javascript:update' do
|
||||
task 'javascript:update_constants' => :environment do
|
||||
constants_js = <<~JS
|
||||
// DO NOT EDIT THIS FILE!!!
|
||||
// Update it by running `rake javascript:update_constants`
|
||||
|
||||
export const SearchPriorities = #{Searchable::PRIORITIES.to_json};
|
||||
|
||||
export const SearchPhraseRegexp = '#{Search::PHRASE_MATCH_REGEXP_PATTERN}';
|
||||
JS
|
||||
|
||||
output_path = "#{Rails.root}/app/assets/javascripts/discourse/app/lib/constants.js"
|
||||
File.write(output_path, constants_js)
|
||||
puts "contants.js created"
|
||||
%x{yarn run prettier --write #{output_path}}
|
||||
puts "constants.js prettified"
|
||||
end
|
||||
|
||||
task 'javascript:update' do
|
||||
require 'uglifier'
|
||||
|
||||
yarn = system("yarn install")
|
||||
|
Reference in New Issue
Block a user