Skip to content

Commit

Permalink
✨ Add should_add_exports() SCSS function
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Mar 3, 2024
1 parent a7e923d commit 0fdf467
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Make `AQL` trail placeholders default to explicit `null` values
* Add the abstract `Meta` field class: these should be used for fields that are not directly stored in the database
* Add association aliases as a meta field to model schemas
* Add `should_add_exports()` SCSS function

## 1.4.0-alpha.3 (2024-02-25)

Expand Down
24 changes: 21 additions & 3 deletions lib/core/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ if (alchemy.settings.frontend.stylesheet.enable_scss) {
}

return result;
}
},
'should_add_exports()': function() {
return sass.types.Boolean.FALSE;
},
};
}

Expand Down Expand Up @@ -1278,9 +1281,20 @@ Alchemy.setMethod(function getCompiledSassPath(sassPath, options, callback) {
return writeToTemp(source);
}

let custom_functions = sass_functions;

if (options.add_exports) {
custom_functions = {
...custom_functions,
'should_add_exports()': function() {
return sass.types.Boolean.TRUE;
},
};
}

const render_options = {
includePaths : styleDirs.getSorted(),
functions : sass_functions,
functions : custom_functions,
importer : customScssImporter,
logger : {
warn : logSassWarning,
Expand Down Expand Up @@ -1469,7 +1483,11 @@ function extractPostCSSExports(postcss_result) {
*/
Alchemy.setMethod(async function extractCSSExports(css_path) {

let result = await findStylesheet(css_path, {post_css_only: true, compile: true});
let result = await findStylesheet(css_path, {
post_css_only: true,
add_exports: true,
compile: true
});

result = extractPostCSSExports(result);

Expand Down

0 comments on commit 0fdf467

Please sign in to comment.