svelte-sequential-preprocessor
v2.0.2
Published
Sequential preprocessor for Svelte JS.
Downloads
52,493
Readme
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.
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 Sapper
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,
// ...
}),
],
},
};