astro-compress middleware
kireerik opened this issue · comments
May make
on
(true
) as the default setting in development mode as well for this new feature.
related issue:
Yeah, you can do:
import compress from "astro-compress";
import { defineConfig } from "astro/config";
export default defineConfig({
integrations: [
import.meta.env.MODE === "production" ? compress() : null,
],
});
But the integration is not enabled in development it's only turned on "astro:build:done"
Apologies you meant, on
. There is currently no way to turn it on in development mode as it served from vite
, but there are plans to make it integrate with the new middleware API https://docs.astro.build/en/guides/middleware/. Expect it in 1.2.0
It's useful to know that you can turn off an integration like that, but it's not specific to astro-compress
Or maybe they have an environment where import.meta.env.MODE
is always development
. I don't know if this is affected by process.env
But he writes compress({html: false})
for development, which is currently the same as doing compress({html: true})
or compress()
, because for some reason in development, it is basically false
regardless for some reason.
Just a preference, I think, but if you put false
in any of the options it should not trigger compression for that specific file type.
But even if I put true
the compression is still not triggered (in development mode).
Yes, but that is regardless of the development mode, if you put true
it will just trigger the compression with the defaults from https://github.com/astro-community/astro-compress/tree/main/src/options
Oh, I see so turning it on in development would be a separate feature because in development mode it is not used anyway (right now). So in development mode, it doesn't matter what options are passed.
Exactly!
The current way it works is just runs after build is done over all files.
The new way would be to attach a middleware to an internal function inside astro-compress
, so that every request gets served compressed, but the file stays unchanged. I already have it in my backlog it should be done in the next couple of days.
I see. Nice. Can you link that issue in your backlog?
Sure. 😁
So can you link that issue in your backlog?
@kireerik It's already linked, you'll get notified once it's done. 😁 The backlog is my personal task list.