A Svelte preprocessor that wraps preprocessors to force them to be called sequentially.
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.
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.
Using npm:
$ npm i -D svelte-sequential-preprocessor
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() ])
})
]
}
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')])
},
},
},
...
]
}
...
// 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;