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

Conditionally include tags based on features #907

Open
Madoshakalaka opened this issue Nov 8, 2024 · 1 comment
Open

Conditionally include tags based on features #907

Madoshakalaka opened this issue Nov 8, 2024 · 1 comment

Comments

@Madoshakalaka
Copy link

Is there a way to conditionally include some <script> tags based on features?

I want to only include some google analytics script tag on production build, as opposed to staging or dev environments

I propose a data-trunk-feature attribute

Say this is in the index.html:

<script data-trunk-feature="analytics" async src=“https://www.googletagmanager.com/gtag/js?id=G-....” ></script>

This will only gets included with trunk build --features analytics

@ctron
Copy link
Collaborator

ctron commented Nov 8, 2024

Interesting idea. Could you come up with a PR for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants