AssetSync/asset_sync

Only enhance `assets:precompile` if it exists

Closed this issue · 4 comments

Hello,

I'm using rails 5.2 with webpacker without sprockets or the assets pipeline, so I don't have a assets:precompile rake task. I manually call asset sync when needed.

Would you be open for a pull request to only enhance assets:precompile when it's defined? Similar as how webpacker does it (ref: https://github.com/rails/webpacker/blob/master/lib/tasks/webpacker/compile.rake)

Regards

Sure! Maybe include the option to skip via env var too :)

@JanStevens Just made a commit to only enhance assets:precompile if it's defined
Can you try master and see if it works?
Will release a new version if it works fine

@PikachuEXE Thanks! I tested it with master and it works

I also had to set some additional config options since they where taken from assets pipeline

AssetSync.configure do |config|
  # Specifies the assets prefix
  config.prefix = '/assets'
  # Don't run on precompile it doesn't exist
  config.run_on_precompile = false
  # The block should return an array of file paths
  config.add_local_file_paths do
    # Any code that returns paths of local asset files to be uploaded
    # Like Webpacker
    public_root = Rails.root.join("public")
    Dir.chdir(public_root) do
      packs_dir = Webpacker.config.public_output_path.relative_path_from(public_root)
      Dir[File.join(packs_dir, '/**/**')]
    end
  end
end

2.5.0 released
Please reopen if you still got this issue :)