Skip to content
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

precompress logic should live in Kit, not adapters #3796

Closed
Rich-Harris opened this issue Feb 9, 2022 · 0 comments · Fixed by #5822
Closed

precompress logic should live in Kit, not adapters #3796

Rich-Harris opened this issue Feb 9, 2022 · 0 comments · Fixed by #5822
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Milestone

Comments

@Rich-Harris
Copy link
Member

Describe the problem

There's no reason for both of these to exist:

/**
* @param {string} directory
*/
async function compress(directory) {
if (!existsSync(directory)) {
return;
}
const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
cwd: directory,
dot: true,
absolute: true,
filesOnly: true
});
await Promise.all(
files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
);
}
/**
* @param {string} directory
*/
async function compress(directory) {
const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
cwd: directory,
dot: true,
absolute: true,
filesOnly: true
});
await Promise.all(
files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
);
}

Describe the proposed solution

The logic should live in Kit itself — adapters should be able to do this sort of thing:

if (options.precompress) {
  await builder.precompress(dir);
}

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@benmccann benmccann added p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc. feature / enhancement New feature or request labels Feb 9, 2022
@Rich-Harris Rich-Harris added this to the 1.0 milestone Apr 28, 2022
@enBonnet enBonnet mentioned this issue Aug 4, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request p2-nice-to-have SvelteKit cannot be used by a small number of people, quality of life improvements, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants