Skip to content

Commit

Permalink
add locale rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYCHuang committed Feb 20, 2017
1 parent 2b8ee6a commit 724eba8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "react_on_rails/assets_precompile"
require "react_on_rails/locales_to_js"

if defined?(Sprockets)
namespace :react_on_rails do
Expand Down Expand Up @@ -50,10 +51,21 @@ Compile assets with webpack
Uses command defined with ReactOnRails.configuration.npm_build_production_command
sh "cd client && `ReactOnRails.configuration.npm_build_production_command`"
DESC
task webpack: :environment do
task webpack: :locale do
if ReactOnRails.configuration.npm_build_production_command.present?
sh "cd client && #{ReactOnRails.configuration.npm_build_production_command}"
end
end

desc <<-DESC
When "ReactOnRails.configuration.i18n_dir" is set, it indeicates that javascript locale files are needed.
This task generates javascript locale files: `translations.js` & `default.js`.
DESC
desc "Generate i18n javascript files"
task locale: :environment do
if ReactOnRails.configuration.i18n_dir.present?
ReactOnRails::LocalesToJs.new
end
end
end
end

0 comments on commit 724eba8

Please sign in to comment.