mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
DEV: Support referencing public images in plugins in SCSS (#12930)
This commit is contained in:
parent
8ca6202d81
commit
9bc126949e
@ -200,7 +200,12 @@ $breakpoints: (
|
||||
// it returns a CDN or subfolder path (if applicable).
|
||||
// SCSS will compile (and return the relative path) if public_image_path is missing.
|
||||
@if variable-exists(public_image_path) {
|
||||
@return url("#{$public_image_path}#{$path}");
|
||||
@if (str-index("#{$path}", "/plugins") == 1) {
|
||||
$plugin_asset_path: str-replace($public_image_path, "/images", "");
|
||||
@return url("#{$plugin_asset_path}#{$path}");
|
||||
} @else {
|
||||
@return url("#{$public_image_path}#{$path}");
|
||||
}
|
||||
} @else {
|
||||
@return url("#{$path}");
|
||||
}
|
||||
|
@ -118,6 +118,16 @@ describe Stylesheet::Compiler do
|
||||
expect(css).not_to include('absolute-image-url')
|
||||
end
|
||||
|
||||
it "supports absolute-image-url in plugins" do
|
||||
set_cdn_url "https://awesome.com"
|
||||
scss = Stylesheet::Importer.new({}).prepended_scss
|
||||
scss += ".body{background-image: absolute-image-url('/plugins/discourse-special/images/somefile.png');}"
|
||||
css, _map = Stylesheet::Compiler.compile(scss, "discourse-special.scss")
|
||||
|
||||
expect(css).to include('url("https://awesome.com/plugins/discourse-special/images/somefile.png")')
|
||||
expect(css).not_to include('absolute-image-url')
|
||||
end
|
||||
|
||||
context "with a color scheme" do
|
||||
it "returns the default color definitions when no color scheme is specified" do
|
||||
css, _map = Stylesheet::Compiler.compile_asset("color_definitions")
|
||||
|
Loading…
Reference in New Issue
Block a user