You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`sass`: `npm install -D node-sass` or `npm install -D sass`
43
45
-`pug`: `npm install -D pug`
@@ -47,7 +49,7 @@ _Note: If you want to load your `postcss` configuration from a external file, ma
47
49
48
50
## Features
49
51
50
-
### Template tag support
52
+
### Template tag
51
53
52
54
Add _vue-like_ support for defining your markup between a `<template>` tag. The tagname can be customized to something like `markup` for example. See [#options](#options).
53
55
@@ -63,15 +65,15 @@ _Note: only for auto preprocessing_
63
65
<script></script>
64
66
```
65
67
66
-
### External files support
68
+
### External files
67
69
68
70
```html
69
71
<templatesrc="./template.html"></template>
70
72
<scriptsrc="./script.js"></script>
71
73
<stylesrc="./style.css"></style>
72
74
```
73
75
74
-
### Global style support
76
+
### Global style
75
77
76
78
Add a `global` attribute to your `style` tag and instead of scoping the css, all of its content will be interpreted as global style.
77
79
@@ -86,9 +88,9 @@ Add a `global` attribute to your `style` tag and instead of scoping the css, all
86
88
_Note<sup>1</sup>: needs postcss to be installed_
87
89
_Note<sup>2</sup>: if you're using it as a standalone processor, it works best if added to the end of the processors array._
88
90
89
-
### Preprocessors support
91
+
### Preprocessors
90
92
91
-
Current supported out-of-the-box preprocessors are `SCSS`, `Stylus`, `Less`, `Coffeescript`, `TypeScript`, `Pug` and `PostCSS`.
93
+
Current supported out-of-the-box preprocessors are `SCSS`, `Stylus`, `Less`, `Coffeescript`, `TypeScript`, `Pug`, `PostCSS`, `Babel`.
92
94
93
95
```html
94
96
<templatelang="pug">
@@ -132,6 +134,38 @@ Current supported out-of-the-box preprocessors are `SCSS`, `Stylus`, `Less`, `Co
132
134
</style>
133
135
```
134
136
137
+
### Modern Javascript syntax
138
+
139
+
`svelte-preprocess` allows you to run your component code through `babel` before sending it to the compiler, allowing you to use new language features such as optional operators and nullish coalescing. However, note that `babel` should transpile your component code to the javascript version supported by the Svelte compiler, so ES6+.
140
+
141
+
For example, with `@babel/preset-env` your config could be:
142
+
143
+
```js
144
+
import preprocess from 'svelte-preprocess'
145
+
...
146
+
preprocess: preprocess({
147
+
babel: {
148
+
presets: [
149
+
[
150
+
'@babel/preset-env',
151
+
{
152
+
loose: true,
153
+
// No need for babel to resolve modules
154
+
modules: false,
155
+
targets: {
156
+
// ! Very important. Target es6+
157
+
esmodules: true,
158
+
},
159
+
},
160
+
],
161
+
],
162
+
},
163
+
});
164
+
...
165
+
```
166
+
167
+
_Note: If you want to transpile your app to be supported in older browsers, you must run babel from the context of your bundler._
0 commit comments