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

Allow to conditionally inline ressources #25

Open
AndyOGo opened this issue Jan 25, 2022 · 2 comments
Open

Allow to conditionally inline ressources #25

AndyOGo opened this issue Jan 25, 2022 · 2 comments

Comments

@AndyOGo
Copy link

AndyOGo commented Jan 25, 2022

This plugin is great.

I would like to utilize some more options of posthtml-inline-assets to inline only certain resources.

My use case is that I need to inline CSS for a splash screen or above the fold content only.

Proposal

  • Either allow to configure filters e.g. with resolve option
  • Or use a declarative approach at the HTML node, e.g. with a data-inline boolean attribute
    <--! will be inlined -->
    <link rel="stylesheet" href="./foo.css" data-inline />
    <script src="./foo.js" data-inline></script>
    <--! will not be inlined -->
    <link rel="stylesheet" href="./bar.css" />
    <script src="./bar.js"></script>

Alternatively if it would work the same as in Parcel V2, that would be great too.
https://parceljs.org/languages/html/#inline-script-and-style-tags

@AndyOGo
Copy link
Author

AndyOGo commented Jan 25, 2022

parcel-plugin-inline-source supports an inline attribute.

@shff
Copy link
Owner

shff commented Feb 22, 2023

About attributes: the main issue here is that there's no support for the inline attribute from posthtml-inline-assets. This is something you gotta ask directly to them, since I'm only a downstream consumer of their package. It doesn't really make sense adding it in this package here.

About using configuration from a JSON or something: I'm not sure if there's a canonical way of adding configuration to a Parcel V1 plugin. I might be wrong. If there is, let me know and I will try.

Also, Parcel V2 requires plugins to be rewritten from scratch. They have a completely new structure, completely different code, and even the name is different, it can't start with parcel-plugin- AFAIK. It would be more of a fork than an update. I'm not in the ecosystem anymore, so I'm not sure if I'm the right person to do it.

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