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

astro-compress middleware #131

Open
kireerik opened this issue May 22, 2023 · 17 comments
Open

astro-compress middleware #131

kireerik opened this issue May 22, 2023 · 17 comments
Assignees
Labels
enhancement New feature or request

Comments

@kireerik
Copy link

kireerik commented May 22, 2023

May make on (true) as the default setting in development mode as well for this new feature.

 
related issue:

@kireerik kireerik changed the title How can I turn this integration on in development mode? How can we turn this integration on in development mode? May 22, 2023
@NikolaRHristov
Copy link
Member

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"

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 22, 2023

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

@NikolaRHristov NikolaRHristov added the enhancement New feature or request label May 22, 2023
@kireerik
Copy link
Author

Yes #76 is confusing for me. Why do @rdwz want to turn it off in development mode when it is not turned on anyway?

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 22, 2023

It's useful to know that you can turn off an integration like that, but it's not specific to astro-compress

@NikolaRHristov
Copy link
Member

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

@kireerik
Copy link
Author

kireerik commented May 22, 2023

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.

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 22, 2023

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.

@kireerik
Copy link
Author

But even if I put true the compression is still not triggered (in development mode).

@NikolaRHristov
Copy link
Member

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

@kireerik
Copy link
Author

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.

@NikolaRHristov
Copy link
Member

Exactly!

@NikolaRHristov
Copy link
Member

The current way it works is just runs after build is done over all files.

@kireerik kireerik changed the title How can we turn this integration on in development mode? Implement option to turn this integration on in development mode as well May 22, 2023
@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 22, 2023

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.

@kireerik kireerik changed the title Implement option to turn this integration on in development mode as well Implement option to turn this integration on in development mode (as well) May 22, 2023
@kireerik
Copy link
Author

I see. Nice. Can you link that issue in your backlog?

@NikolaRHristov
Copy link
Member

Sure. 😁

@kireerik
Copy link
Author

So can you link that issue in your backlog?

@NikolaRHristov
Copy link
Member

NikolaRHristov commented May 25, 2023

@kireerik It's already linked, you'll get notified once it's done. 😁 The backlog is my personal task list.

image
image

@NikolaRHristov NikolaRHristov changed the title Implement option to turn this integration on in development mode (as well) astro-compress middleware Jul 20, 2023
@NikolaRHristov NikolaRHristov self-assigned this Sep 9, 2023
@NikolaRHristov NikolaRHristov added enhancement New feature or request and removed enhancement New feature or request hacktoberfest labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants