svelte-sequential-preprocessor Svelte Themes

Svelte Sequential Preprocessor

A Svelte preprocessor that wraps preprocessors to force them to be called sequentially.

svelte-sequential-preprocessor

A Svelte preprocessor that wraps preprocessors to force them to be called sequentially.

Overview

Svelte evaluates preprocessors by running all markup preprocessors first, then script and finally styles. Some preprocesses may not work if other preprocessors haven't been run. For example, svelte-image uses svelte.parse() internally, so svelte-preprocess needs to be run before if any scss is present.

:warning: Deprecation Notice :warning:

Since Svelte 4 this has been the default behaviour. I plan to continue to apply package updates periodically to apply security updates, but please migrate away from this package when you can.

More details of the Svelte implementation can be found here:

I would like to take this opportunity to thank everyone for your support over the years. If there is any use case this package is still needed for, please raise an issue, and I will consider keeping the project alive a bit longer.

Installation

Using npm:

$ npm i -D svelte-sequential-preprocessor

Usage

With rollup-plugin-svelte

// rollup.config.js
import svelte from 'rollup-plugin-svelte';
import seqPreprocessor from 'svelte-sequential-preprocessor'
import autoPreprocess from 'svelte-preprocess'
import image from 'svelte-image'

export default {
  ...,
  plugins: [
    svelte({
      preprocess: seqPreprocessor([ autoPreprocess(), image() ])
    })
  ]
}

With svelte-loader

  ...
  module: {
    rules: [
      ...
      {
        test: /\.(html|svelte)$/,
        exclude: /node_modules/,
        use: {
          loader: 'svelte-loader',
          options: {
            preprocess: require('svelte-sequential-preprocessor')([ require('svelte-preprocess'), require('svelte-image')])
          },
        },
      },
      ...
    ]
  }
  ...

With SvelteKit

// svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import seqPreprocessor from 'svelte-sequential-preprocessor';
import autoPreprocess from 'svelte-preprocess';
import image from 'svelte-image';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: seqPreprocessor([autoPreprocess(), image()]),

  kit: {
    adapter: adapter()
  }
};

export default config;

Top categories

Loading Svelte Themes