Installation
Add Vize to your dependencies:
def deps do
[{:vize, "~> 0.17"}]
endVize is a Rust NIF. mix deps.get downloads a precompiled build for your platform:
- macOS on Apple Silicon and Intel
- Linux on x86-64 and ARM64 (glibc), and x86-64 (musl)
- Windows on x86-64 (MSVC)
Building from source
Set VIZE_EX_BUILD=1 to compile the NIF instead of downloading it. This needs Rust 1.95 or later; rustup is the easiest way to install it.
VIZE_EX_BUILD=1 mix deps.compile vize
First steps
Every function returns {:ok, result} or {:error, reason}, and most have a ! variant that raises instead.
Compile a component:
source = """
<template><p :class="cls">{{ msg }}</p></template>
<script setup>
const cls = "greeting"
const msg = "Hello"
</script>
<style scoped>p { color: red }</style>
"""
{:ok, result} = Vize.compile_sfc(source, filename: "Greeting.vue")
result.code # JavaScript module
result.css # CSS scoped to this component
result.errors # []Read it without compiling:
{:ok, descriptor} = Vize.parse_sfc(source)
descriptor.template.content
descriptor.script_setup.content
hd(descriptor.styles).scoped # trueCompile CSS on its own:
{:ok, result} = Vize.CSS.compile(".a { color: red }", minify: true)
result.code # ".a{color:red}"Next
- Single-file components: compile options, hashes, scope IDs, assets, and
.d.ts - Analysis and linting
- Vapor mode and the Vapor IR
- Templates and SSR
- CSS
- API cheatsheet