Skip to content

Commit d055320

Browse files
committed
docs: add migration guide
1 parent fae6ad8 commit d055320

File tree

3 files changed

+95
-18
lines changed

3 files changed

+95
-18
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [What is it?](#what-is-it)
2020
- [Getting Started](docs/getting-started.md)
2121
- [Usage](docs/usage.md)
22+
- [Migration Guide](docs/migration-guide.md)
2223
- [Preprocessing](docs/preprocessing.md)
2324
- [Preprocessors](docs/preprocessing.md#preprocessors)
2425
- [Features](#features)
@@ -200,6 +201,8 @@ The current supported languages out-of-the-box are Sass, Stylus, Less, CoffeeScr
200201

201202
### [Usage documentation](/docs/usage.md)
202203

204+
### [Migration Guide](/docs/migration-guide.md)
205+
203206
---
204207

205208
## License

docs/migration-guide.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Migration Guide
2+
3+
<!-- @import "[TOC]" {cmd="toc" depthFrom=2 depthTo=6 orderedList=false} -->
4+
5+
<!-- code_chunk_output -->
6+
7+
- [Migration Guide](#migration-guide)
8+
- [From `v3` to `v4`](#from-v3-to-v4)
9+
- [Prepending content to `scss`](#prepending-content-to-scss)
10+
- [Executing some function before preprocessing](#executing-some-function-before-preprocessing)
11+
- [Defining preprocessor properties](#defining-preprocessor-properties)
12+
- [Type-checking components](#type-checking-components)
13+
14+
<!-- /code_chunk_output -->
15+
16+
## From `v3` to `v4`
17+
18+
### Prepending content to `scss`
19+
20+
In `v3`, it was possible to prepend some content for the `scss` language through the `data` property.
21+
22+
```js
23+
import sveltePreprocess from 'svelte-preprocess';
24+
25+
sveltePreprocess({
26+
scss: {
27+
data: '// prepended content',
28+
},
29+
});
30+
```
31+
32+
In `v4`, not only `scss`, but every language preprocessor accepts the new `prependData` property. The `data` property is no longer supported.
33+
34+
```js
35+
import sveltePreprocess from 'svelte-preprocess';
36+
37+
sveltePreprocess({
38+
scss: {
39+
prependData: '// prepended content for scss',
40+
},
41+
typescript: {
42+
prependData: '// prepended content for ts',
43+
},
44+
});
45+
```
46+
47+
### Executing some function before preprocessing
48+
49+
The previously `onBefore` property was removed. Instead, enqueue a custom preprocessor before `svelte-preprocess`.
50+
51+
```js
52+
// v3
53+
54+
{
55+
preprocess: sveltePreprocess({
56+
onBefore({ content, filename }) {
57+
return content.replace('foo', 'bar');
58+
},
59+
});
60+
}
61+
62+
// v4
63+
const myPreprocessor = {
64+
markup({ content }) {
65+
return { code: content.replace('foo', 'bar') };
66+
},
67+
};
68+
69+
// later in your config
70+
{
71+
preprocess: [myPreprocessor, sveltePreprocess()];
72+
}
73+
```
74+
75+
### Defining preprocessor properties
76+
77+
The previously `transformers` property was removed. Instead, define your preprocessor options in the root object of `svelte-preprocess` auto-preprocessor.
78+
79+
```diff
80+
import sveltePreprocess from 'svelte-preprocess';
81+
82+
sveltePreprocess({
83+
- transformers: {
84+
scss: { ... }
85+
- }
86+
});
87+
```
88+
89+
### Type-checking components
90+
91+
> TODO

docs/preprocessing.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -333,24 +333,7 @@ You can check the [Sass API reference](https://sass-lang.com/documentation/js-ap
333333

334334
### Stylus
335335

336-
You can check the [Stylus API reference](https://stylus-lang.com/docs/js.html) for specific Stylus options. The `filename` is not supported.
337-
338-
```js
339-
import svelte from 'rollup-plugin-svelte'
340-
341-
import { stylus } from 'svelte-preprocess'
342-
343-
export default {
344-
...
345-
plugins: [
346-
svelte({
347-
preprocess: [
348-
stylus({ ... }),
349-
]
350-
})
351-
]
352-
}
353-
```
336+
You can check the [Stylus API reference](https://stylus-lang.com/docs/js.html) for specific Stylus options. The `filename` property is overriden.
354337

355338
### TypeScript
356339

0 commit comments

Comments
 (0)