0

I've been using asset_sync, to move our static assets to Amazon S3, and I've noticed that when I precompile my assets (using foreman run rake assets:precompile), the base directories get flattened. They go from:

/app
  /assets/
    /images
      image.png
      image2.png
      /subdir
        image3.png
    /javascripts
      script.js
    /stylesheets
      style.css

To:

/public
  /assets/
    image.png
    image2.png
    /subdir
      image3.png
    script.js
    style.css

It keeps any subdirectories, but the base directories get removed for some reason.

Is it possible to disable this? I'd like to keep my S3 assets organized into directories. I could probably resolve this by adding additional directories so that the structure is the following.

/app
  /assets/
    /images
      /images
        image.png
        image2.png
        /subdir
          image3.png
    /javascripts
      /javascripts
        script.js
    /stylesheets
      /stylesheets
        style.css

But that just seems like a dirty solution.

I'm configuring my assets for precompiling with:

Rails.application.config.assets.precompile = []
Rails.application.config.assets.precompile += ['application.js']
Rails.application.config.assets.precompile += Loader.js_files
Rails.application.config.assets.precompile += ['*.css', '*.png', '*.svg', '*.jpg']

My environment has the following variables":

ASSET_SYNC_GZIP_COMPRESSION=true
ASSET_SYNC_MANIFEST=true
ASSET_SYNC_EXISTING_REMOTE_FILES=keep
AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxx
FOG_DIRECTORY=aws-example
FOG_PREFIX=/assets/
FOG_PROVIDER=AWS
FOG_REGION=us-west-1
Adam
  • 4,445
  • 1
  • 31
  • 49

1 Answers1

0

Have you configured asset_sync correctly for the application you are creating?

AssetSync.configure do |config|
  config.fog_provider = 'AWS'
  config.fog_directory = ENV['FOG_DIRECTORY']
  config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
  config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
  config.prefix = 'assets'
  config.public_path = Pathname('./public')
end

Depending on the type of application you need to configure the prefix and the public_path. Check out the Sinatra/Rack support section https://github.com/AssetSync/asset_sync for more information. Hope puts you on the right path.

tomjohn
  • 321
  • 3
  • 12