# `Vize.SFC`
[🔗](https://github.com/elixir-volt/vize_ex/blob/v0.17.2/lib/vize/sfc.ex#L1)

Bundler-oriented helpers for Vue Single File Components.

These helpers expose Vize's SFC dependency and scope-ID logic without
requiring callers to reimplement Vue template parsing with regular
expressions.

# `collect_template_assets`

```elixir
@spec collect_template_assets(
  String.t(),
  keyword()
) :: {:ok, [Vize.SFC.Asset.t()]} | {:error, Vize.Error.t()}
```

Collect importable static asset references from an SFC template.

By default Vize recognizes assets such as `img[src]`, `video[src]`,
`video[poster]`, `source[src]`, and SVG image/use references.

## Options

  * `:filename` — filename used when parsing the SFC

# `collect_template_assets!`

```elixir
@spec collect_template_assets!(
  String.t(),
  keyword()
) :: [Vize.SFC.Asset.t()]
```

Like `collect_template_assets/2` but raises `Vize.Error` on parse errors.

# `external_sources`

```elixir
@spec external_sources(String.t()) ::
  {:ok, [Vize.SFC.ExternalSource.t()]} | {:error, Vize.Error.t()}
```

Collect SFC blocks whose contents are loaded through a `src` attribute.

Returns template, script, script-setup, style, and custom-block sources.

# `external_sources!`

```elixir
@spec external_sources!(String.t()) :: [Vize.SFC.ExternalSource.t()]
```

Like `external_sources/1` but raises `Vize.Error` on parse errors.

# `rewrite_asset_references`

```elixir
@spec rewrite_asset_references(String.t(), [Vize.SFC.Asset.t()]) :: String.t()
```

Rewrite asset literals in compiled SFC JavaScript to imported bindings.

`assets` should be the result of `collect_template_assets/2`. The function is
total: JavaScript that cannot be parsed is returned unchanged.

# `scope_id`

```elixir
@spec scope_id(
  String.t(),
  keyword()
) :: String.t()
```

Generate the deterministic scope ID used by Vize's bundler integrations.

## Options

  * `:root` — project root used to normalize the filename
  * `:production` — use the production hashing strategy
  * `:source` — source content included by the production strategy

---

*Consult [api-reference.md](api-reference.md) for complete listing*
