-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add imported_asset_path_processor config directive.
- Loading branch information
Brad Chen
committed
Aug 26, 2016
1 parent
76b1716
commit 0927d98
Showing
2 changed files
with
98 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Feature: Imported assets can be placed in paths determined by a processor | ||
|
||
Background: | ||
Given a fixture app "base-app" | ||
And a file named "config.rb" with: | ||
""" | ||
activate :sprockets do |config| | ||
config.imported_asset_path_processor = ->(asset) { | ||
if asset.logical_path =~ /\.js$/ | ||
File.join('vendor-js', asset.logical_path) | ||
elsif asset.logical_path =~ /^images\// | ||
'vendor-' + asset.logical_path | ||
elsif asset.logical_path =~ /^fonts\// | ||
'3rd-party-' + asset.logical_path | ||
else | ||
asset.logical_path | ||
end | ||
} | ||
end | ||
sprockets.append_path File.join(root, 'vendor') | ||
""" | ||
And a file named "vendor/fonts/webfont-vendor.svg" with: | ||
""" | ||
""" | ||
And a file named "vendor/fonts/webfont-vendor.svg.gz" with: | ||
""" | ||
""" | ||
And a file named "vendor/fonts/webfont-vendor.ttf.gz" with: | ||
""" | ||
""" | ||
And a file named "source/fonts/webfont-source.svg" with: | ||
""" | ||
""" | ||
And a file named "source/fonts/webfont-source.svg.gz" with: | ||
""" | ||
""" | ||
And a file named "source/fonts/webfont-source.ttf.gz" with: | ||
""" | ||
""" | ||
And a file named "vendor/images/drawing-vendor.svg" with: | ||
""" | ||
""" | ||
And a file named "source/images/drawing-source.svg" with: | ||
""" | ||
""" | ||
And a file named "vendor/images/extensions-source.svg.gz" with: | ||
""" | ||
""" | ||
And a file named "vendor/images/extensions-source.min.js" with: | ||
""" | ||
""" | ||
And a file named "vendor/images/extensions-source.asdf.asdf.min.js.asdf" with: | ||
""" | ||
""" | ||
|
||
|
||
Scenario: Assets built by being linked are built with the right extension | ||
Given a file named "source/stylesheets/manifest.css" with: | ||
""" | ||
//= link 'fonts/webfont-vendor.svg' | ||
//= link 'fonts/webfont-vendor.svg.gz' | ||
//= link 'fonts/webfont-vendor.ttf.gz' | ||
//= link 'images/drawing-vendor.svg' | ||
//= link 'images/extensions-source.svg.gz' | ||
//= link 'images/extensions-source.min.js' | ||
//= link 'images/extensions-source.asdf.asdf.min.js.asdf' | ||
""" | ||
And a successfully built app | ||
|
||
When I cd to "build" | ||
Then the following files should exist: | ||
| 3rd-party-fonts/webfont-vendor.svg | | ||
| 3rd-party-fonts/webfont-vendor.svg.gz | | ||
| 3rd-party-fonts/webfont-vendor.ttf.gz | | ||
| vendor-images/drawing-vendor.svg | | ||
| vendor-images/extensions-source.svg.gz | | ||
| vendor-images/extensions-source.asdf.asdf.min.js.asdf | | ||
| vendor-js/images/extensions-source.min.js | | ||
|
||
Scenario: Assets in source don't have their extensions mangled | ||
Given a successfully built app | ||
|
||
When I cd to "build" | ||
Then the following files should exist: | ||
| fonts/webfont-source.svg | | ||
| fonts/webfont-source.svg.gz | | ||
| fonts/webfont-source.ttf.gz | | ||
| images/drawing-source.svg | |
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