-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support <link> elements in svelte (#426)
* feat: add basic <link> support * docs: add <link> references * chore: snapshot update
- Loading branch information
Showing
12 changed files
with
812 additions
and
1,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Svelte | ||
|
||
`modular-css-svelte` provides a [svelte preprocessor](https://svelte.technology/guide#preprocessing) that can convert inline `<style>` or external `<link>` tags using `modular-css` and will also staticly replace any css references it can find for maximum speed. | ||
|
||
### Options | ||
|
||
All options are passed to the underlying `Processor` instance, see [Options](api.md#options). | ||
|
||
## Usage | ||
|
||
### `svelte.preprocess()` | ||
|
||
```js | ||
const filename = "./Component.html"; | ||
|
||
const { processor, preprocess } = require("modular-css-svelte")({ | ||
css : "./dist/bundle.css" | ||
}); | ||
|
||
const processed = await svelte.preprocess( | ||
fs.readFileSync(filename, "utf8"), | ||
Object.assign({}, preprocess, { filename }) | ||
); | ||
|
||
const result = processor.output(); | ||
|
||
fs.writeFileSync("./dist/bundle.css", result.css); | ||
``` | ||
|
||
### `rollup-plugin-svelte` | ||
|
||
#### API | ||
|
||
```js | ||
const rollup = require("rollup").rollup; | ||
|
||
const { preprocess, plugin } = require("modular-css-svelte/rollup")({ | ||
css : "./dist/bundle.css" | ||
}); | ||
|
||
const bundle = await rollup({ | ||
input : "./Component.html", | ||
plugins : [ | ||
require("rollup-plugin-svelte")({ | ||
preprocess | ||
}), | ||
plugin | ||
] | ||
}); | ||
|
||
// bundle.write will also write out the CSS to the path specified in the `css` arg | ||
bundle.write({ | ||
format : "es", | ||
file : "./dist/bundle.js" | ||
}); | ||
``` | ||
|
||
#### `rollup.config.js` | ||
|
||
```js | ||
const { preprocess, plugin } = require("modular-css-svelte/rollup")({ | ||
css : "./dist/bundle.css" | ||
}); | ||
|
||
module.exports = { | ||
input : "./Component.html", | ||
output : { | ||
format : "es", | ||
file : "./dist/bundle.js" | ||
}, | ||
plugins : [ | ||
require("rollup-plugin-svelte")({ | ||
preprocess | ||
}), | ||
plugin | ||
] | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.