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.
Using npm:
$ npm i -D svelte-sequential-preprocessor
// 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() ])
})
]
}
...
module: {
rules: [
...
{
test: /\.(html|svelte)$/,
exclude: /node_modules/,
use: {
loader: 'svelte-loader',
options: {
preprocess: require('svelte-sequential-preprocessor')([ require('svelte-preprocess'), require('svelte-image')])
},
},
},
...
]
}
...
import seqPreprocessor from 'svelte-sequential-preprocessor';
import autoPreprocess from 'svelte-preprocess'
import image from 'svelte-image'
const preprocess = seqPreprocessor([ autoPreprocess(), image() ]);
export default {
client: {
plugins: [
svelte({
preprocess,
// ...
}),
},
server: {
plugins: [
svelte({
preprocess,
// ...
}),
],
},
};