This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
forked from AssetSync/asset_sync
-
Notifications
You must be signed in to change notification settings - Fork 0
add webpacker assets to local files for storage if webpacker config set #1
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
90a21f2
add webpacker assets to local files for storage if webpacker config set
cameronjacoby af88f43
add check for ENV['ASSET_SYNC_INCLUDE_WEBPACKER_ASSETS'] in engine co…
cameronjacoby d4920dc
enhance webpacker:compile task to sync assets
cameronjacoby 56ab7a1
use stubs to set up Webpacker::Configuration.paths instead of overrid…
cameronjacoby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,42 @@ | |
describe AssetSync::Storage do | ||
include_context "mock Rails without_yml" | ||
|
||
describe '#local_files' do | ||
context 'default' do | ||
let(:config) { AssetSync::Config.new } | ||
let(:storage) { AssetSync::Storage.new(config) } | ||
|
||
it 'returns directories and files inside public/assets' do | ||
expect(storage.local_files).to eq([ | ||
'assets/javascripts', | ||
'assets/javascripts/application.js', | ||
]) | ||
end | ||
end | ||
|
||
context 'with include_webpacker_assets = true' do | ||
let(:config) do | ||
config = AssetSync::Config.new | ||
config.include_webpacker_assets = true | ||
config | ||
end | ||
|
||
let(:storage) { AssetSync::Storage.new(config) } | ||
|
||
module Webpacker | ||
class Configuration | ||
def self.paths | ||
{} | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be dangerous. Could we use RSpec's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely - I'll update! |
||
|
||
it 'includes files inside public/packs' do | ||
expect(storage.local_files).to include('packs/manifest.json') | ||
end | ||
end | ||
end | ||
|
||
describe '#upload_files' do | ||
before(:each) do | ||
@local_files = ["local_image2.jpg", "local_image1.jpg", "local_stylesheet1.css", "local_stylesheet2.css"] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbusser I took this exactly from AssetSync#341, but I also considered this simpler approach:
It seems strange to me to check
AssetSync.config.include_webpacker_assets
, since we're already doing that inside ofassets:sync
. I also feel like it could get us into a situation where assets just don't get synced at all ifRake::Task.task_defined?("webpacker:compile")
returns false, butAssetSync.config.include_webpacker_assets
returns true (see line 39).Anyway, I think it may be better to just keep this part simple to focus on which task we're enhancing and make sure assets get synced either way. Let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I understand what's going on here. I thought your simpler version would work, but I think the implementation
we stolethat inspired this fork is probably better.The intention is to ensure that we enhance either the "webpacker:compile" or "assets:precompile" tasks but never both. I have no idea why someone would have the webpacker gem installed and then say "nah, don't sync that like all my other assets," but here we are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and I think the implementation that "inspired" this PR does that with FashionThing's setup (since
Rake::Task.task_defined?("webpacker:compile")
andAssetSync.config.include_webpacker_assets
will both be true), so I'll leave it as is. 👍