Skip to content

Astro inlines script and style for astro islands even with assetsInlineLimit set to 0 #2150

@gerjon-eatch

Description

@gerjon-eatch

Astro's docs here: https://docs.astro.build/en/guides/troubleshooting/#refused-to-execute-inline-script suggest the following config to force script and styles to be not inlined, so that an astro generated site is comptible with Content-Security-Policy that doesn't allow unsafe-inline:

export default defineConfig({
  vite: {
    build: {
      assetsInlineLimit: 0,
    },
  },
});

This works for a site that uses simple Astro components. It stops working once you start using the Astro Islands architecture to hydrate e.g. svelte components. Astro always inlines the island hydration script and related style, even wiht the above configuration.

It would be nice if the documentation could be updated to reflect this. Hopefully with an alternative way to achieve the island hydration script and style not to be inlined in the html..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions