houdini/lib/tasks/i18n_js.rake

44 lines
1.2 KiB
Ruby
Raw Normal View History

2020-11-24 22:20:51 +00:00
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
2021-03-12 20:32:36 +00:00
def enhance_assets_precompile
# yarn:install was added in Rails 5.1
Rake::Task['assets:precompile'].enhance(['i18n:js:export'])
2021-03-12 20:32:36 +00:00
end
def enhance_webpacker_compile
Rake::Task['webpacker:compile'].enhance(['i18n:js:export'])
end
def enhance_webpacker_clean
Rake::Task['webpacker:clean'].enhance(['i18n:js:clean'])
2021-03-12 20:32:36 +00:00
end
def enhance_assets_clean_and_clobber
Rake::Task['assets:clean'].enhance(['i18n:js:clean'])
Rake::Task['assets:clobber'].enhance(['i18n:js:clean'])
2021-03-12 20:32:36 +00:00
end
desc 'For generating the i18n-js exports at runtime. Overrides the built in i18n-js task'
2020-11-24 22:20:51 +00:00
namespace :i18n do
namespace :js do
desc 'Export locales to Typescript'
task export: :environment do
2020-11-24 22:20:51 +00:00
GenerateLocales.generate
end
desc 'Delete all of the generated Javascript locales files'
2021-03-12 20:32:36 +00:00
task clean: :environment do
locales_dir = Rails.root.join('app/javascript/i18n/locales')
FileUtils.remove_dir(locales_dir) if Dir.exist? locales_dir
2020-11-24 22:20:51 +00:00
end
end
2021-03-12 20:32:36 +00:00
end
enhance_assets_precompile
enhance_webpacker_compile
enhance_webpacker_clean
enhance_assets_clean_and_clobber