Skip to content

Make it possible to have image assets flow into sass partials from dif… #181

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

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .core/gulp.tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,15 @@ const reactium = (gulp, config, webpackConfig) => {

const pluginAssetsTemplate = data => {
const template = handlebars.compile(`
@use "sass:map";

$assets: () !default;

// Generated Data URLs from plugin-assets.json
$assets: (
{{#each this}}
'{{key}}': '{{{dataURL}}}',
{{/each}}
);`);
{{#each this}}
$assets: map.set($assets, "{{key}}", "{{{dataURL}}}");
{{/each}}
`);

return template(data);
};
Expand All @@ -501,7 +504,6 @@ $assets: (
for (const file of files) {
const manifest = path.resolve(file);
const base = path.dirname(manifest);

try {
let assets = fs.readFileSync(manifest);
assets = JSON.parse(assets);
Expand All @@ -510,6 +512,15 @@ $assets: (
const mappings = [];
for (const entry of entries) {
const [key, fileName] = entry;
console.log(
`Adding ${key}: ${path.resolve(
base,
fileName,
)} to partial at ${path.resolve(
base,
'_plugin-assets.scss',
)}`,
);
const dataURL = await fileReader(
new File(path.resolve(base, fileName)),
);
Expand Down