feat(ctr): Dynamically generate spritesheets#288
Conversation
still unsure if this should be an ESBuild plugin or just run manually
not automated oops
….sp-whatever shoud allow for neater css if all the sprites have the same class
mrjvs
left a comment
There was a problem hiding this comment.
Looks good, I'll give it a test when I next have a chance (wednesday probably)
An idea, have you considered making the spritesmith script an esbuild plugin?
It would make it so you don't have to run it manually, then we can also add the output files to the ignore.
It doesn't have to be complicated, you can hook into onEnd to just run the script you already have:
import fs from "fs/promises";
import path from "path";
const myPlugin = {
name: "my-plugin",
setup(build) {
build.onEnd(async result => {
if (result.errors.length > 0) return;
const outdir = build.initialOptions.outdir;
if (!outdir) return;
const filePath = path.join(outdir, "my-file.js");
await fs.writeFile(filePath, 'hello-world');
});
},
};|
My only concern with making it a build plugin is that anything we do with #266 needs to be automated in the build process rather than in the repo, since the spritesheet image itself is generated dynamically. The 3DS especially benefits from image optimisation. |
|
yup, pure oxipng should work. the sheet is fairly small and you only update it on changes as you said so zopfli is fair game. the other programs i've mentioned are nice to have but getting them in a raw linux env is nowhere as easy as oxipng and downloading questionably licensed binaries from random forums isn't exactly a good idea for reproducibility :p |
|
^ agree! |
|
Oki. I can try to add a build step for this, at least for stuff that passes through ESBuild. |
|
If curious, here's the results of the new oxipng plugin against just the CTR assets: Not bad! |
mrjvs
left a comment
There was a problem hiding this comment.
I've tested everything and it looks good. Should be ready to merge after fixing the one tooling bug.
mrjvs
left a comment
There was a problem hiding this comment.
The nodemon reload works now. So it's good to merge!
Resolves #XXX
Changes:
The old Juxt spritesheet system had a lot of up/down scaling of the sprites, background positioning mixed with normal styling, and other things that made it very hard to adjust any layouts involving sprites at all. This PR:
Every effort was kept to keep the same layout (or slightly improve it) but like anything that touches Juxt's stylesheets, a bit of shifting around is kinda inevitable. Something something redesign something something new markup.