Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rake, assets): commented assets.rake #1

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
# frozen_string_literal: true

require "react_on_rails/assets_precompile"
require "active_support"
# require "react_on_rails/assets_precompile"
# require "active_support"

if defined?(Sprockets)
namespace :react_on_rails do
namespace :assets do
desc "Creates non-digested symlinks for the assets in the public asset dir"
task symlink_non_digested_assets: :"assets:environment" do
ReactOnRails::AssetsPrecompile.new.symlink_non_digested_assets
end
# if defined?(Sprockets)
# namespace :react_on_rails do
# namespace :assets do
# desc "Creates non-digested symlinks for the assets in the public asset dir"
# task symlink_non_digested_assets: :"assets:environment" do
# ReactOnRails::AssetsPrecompile.new.symlink_non_digested_assets
# end

desc "Cleans all broken symlinks for the assets in the public asset dir"
task delete_broken_symlinks: :"assets:environment" do
ReactOnRails::AssetsPrecompile.new.delete_broken_symlinks
end
# desc "Cleans all broken symlinks for the assets in the public asset dir"
# task delete_broken_symlinks: :"assets:environment" do
# ReactOnRails::AssetsPrecompile.new.delete_broken_symlinks
# end

# In this task, set prerequisites for the assets:precompile task
desc <<-DESC.strip_heredoc
Create webpack assets before calling assets:environment
The webpack task must run before assets:environment task.
Otherwise Sprockets cannot find the files that webpack produces.
This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
DESC
task compile_environment: :webpack do
Rake::Task["assets:environment"].invoke
end
# # In this task, set prerequisites for the assets:precompile task
# desc <<-DESC.strip_heredoc
# Create webpack assets before calling assets:environment
# The webpack task must run before assets:environment task.
# Otherwise Sprockets cannot find the files that webpack produces.
# This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
# DESC
# task compile_environment: :webpack do
# Rake::Task["assets:environment"].invoke
# end

desc "Delete assets created with webpack, in the generated assetst directory (/app/assets/webpack)"
task clobber: :environment do
ReactOnRails::AssetsPrecompile.new.clobber
end
end
end
# desc "Delete assets created with webpack, in the generated assetst directory (/app/assets/webpack)"
# task clobber: :environment do
# ReactOnRails::AssetsPrecompile.new.clobber
# end
# end
# end

# These tasks run as pre-requisites of assets:precompile.
# Note, it's not possible to refer to ReactOnRails configuration values at this point.
Rake::Task["assets:precompile"]
.clear_prerequisites
.enhance([:environment, "react_on_rails:assets:compile_environment"])
.enhance do
Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
end
end
# # These tasks run as pre-requisites of assets:precompile.
# # Note, it's not possible to refer to ReactOnRails configuration values at this point.
# Rake::Task["assets:precompile"]
# .clear_prerequisites
# .enhance([:environment, "react_on_rails:assets:compile_environment"])
# .enhance do
# Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
# Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
# end
# end

# Sprockets independent tasks
namespace :react_on_rails do
namespace :assets do
desc <<-DESC.strip_heredoc
Compile assets with webpack
Uses command defined with ReactOnRails.configuration.build_production_command
# # Sprockets independent tasks
# namespace :react_on_rails do
# namespace :assets do
# desc <<-DESC.strip_heredoc
# Compile assets with webpack
# Uses command defined with ReactOnRails.configuration.build_production_command

sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
DESC
task webpack: :locale do
if Rake::Task.task_defined?("webpacker:compile")
# TODO: Eventually, this will need reconsideration if we use any of the Webpacker compilation
Rake::Task["webpacker:compile"].clear
end
# sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
# DESC
# task webpack: :locale do
# if Rake::Task.task_defined?("webpacker:compile")
# # TODO: Eventually, this will need reconsideration if we use any of the Webpacker compilation
# Rake::Task["webpacker:compile"].clear
# end

if ReactOnRails.configuration.build_production_command.present?
sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
ReactOnRails.configuration.build_production_command
).to_s
end
end
end
end
# if ReactOnRails.configuration.build_production_command.present?
# sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
# ReactOnRails.configuration.build_production_command
# ).to_s
# end
# end
# end
# end