Skip to content

Externalise scripts and styles when prerendering #3555

Open
@Rich-Harris

Description

@Rich-Harris

Describe the problem

In certain situations it makes sense to externalise inline scripts and styles for CSP purposes (e.g. when building Chrome extensions).

Describe the proposed solution

This only really applies to prerendered pages (there's basically no good way to externalise a dynamically rendered script), so I propose the following interface:

// svelte.config.js
export default {
  kit: {
    prerender: {
      externalise: true
    }
  }
};

This would override the inlineStyleThreshold option. (If externalise isn't descriptive enough, we can bikeshed this.)

This would write out an inline script to the filesystem for each prerendered page, under the appDir (so the script can be cached immutably).

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions