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

Only enhance assets:precompile if it exists #372

Closed
JanStevens opened this issue Oct 12, 2018 · 4 comments
Closed

Only enhance assets:precompile if it exists #372

JanStevens opened this issue Oct 12, 2018 · 4 comments

Comments

@JanStevens
Copy link
Contributor

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

@PikachuEXE
Copy link
Member

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

@PikachuEXE
Copy link
Member

@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

@JanStevens
Copy link
Contributor Author

JanStevens commented Oct 19, 2018

@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

@PikachuEXE
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants