Skip to content

Commit

Permalink
docs: You can now include CSS manually if it's a top-level entry in y…
Browse files Browse the repository at this point in the history
…our `vite.config.js` (rather than being imported into your JavaScript) via `craft.vite.asset("src/css/app.css")` ([#31](#31))
  • Loading branch information
khalwat committed Jan 25, 2023
1 parent 3624735 commit 550d7e5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/docs/index.md
Expand Up @@ -714,6 +714,32 @@ If you need to access assets that are in the `public/` directory from Twig, ther
{{ craft.vite.asset("src/images/quote-open.svg", true) }}
```
#### Using `craft.vite.asset` with CSS
If you are using Vite 3.x or later, you can also use `craft.vite.asset` to manually include CSS that is a top-level entry in your `vite.config.js` (rather than being imported into your JavaScript):
```twig
{{ craft.vite.asset("src/css/app.css") }}
```
This assumes your `vite.config.js` looks something like this:
```js
build: {
emptyOutDir: true,
manifest: true,
rollupOptions: {
input: {
app: 'src/js/app.ts',
css: 'src/css/app.css'
},
output: {
sourcemap: true
},
}
},
```
### The `.inline()` function
The Vite plugin also includes a `.inline()` function that inlines the contents of a local file (via path) or remote
Expand Down

0 comments on commit 550d7e5

Please sign in to comment.