#Disable css inlining for one css file

1 messages · Page 1 of 1 (latest)

oak agate
#

Hello, I'm building an integration for astro for my css library.
I want to include the style file to every page:

export default function LinwoodStyleIntegration(): AstroIntegration {
  return {
    name: "linwood-style-astro",
    hooks: {
      "astro:config:setup": async ({ config, updateConfig, injectScript }) => {
        injectScript(
          "page-ssr",
          `import "linwood-style-astro/base.css";`
        );
      },
    },
  };
}

The base.css file looks like this:

@import url("linwood-style-web/css/linwood_style.css");

If I build the demo project, the whole linwood_style.css will be included as inline css. How can I disable this?

arctic burrow
oak agate
#

Not very big but it doesn't change on every page

#

When caching this css file it would be better than inlining it on every page

#

2,4 kb

arctic burrow
oak agate
#

But then every stylesheet won't be inline when adding this integration?

arctic burrow
#

Ya, AFAIK there is not a way to not inline only one file

oak agate
#

Hmm okay...

#

Can I add a file to public and link it manually?

arctic burrow
#

It is possible to copy files to public but there is not a built in way of doing it, most people use pre/post build CLI commands to do it

#

You could export a <Head> component that contains a link to your css file, but people would have to replace the head with your component

oak agate
#

Hmm okay, then I just use the default inline one

#

it shouldn't be a big problem

arctic burrow
#

Ok, let me know if you need any more help!

oak agate
#

Yeah, maybe it can be added as a new feature? ?external?

#

or ?no-inline

arctic burrow
#

I suggest posting in the #feedback-ideas channel where more people can see the idea (including @arshxcx who implemented the feature)