# @nkduy/plugin-kdu

> Note: requires `@kdu/compiler-sfc` as peer dependency. This is largely a port of `rollup-plugin-kdu` with some vite-specific tweaks.

Latest version **1.1.0** (published 2022-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nkduy/plugin-kdu
pnpm add @nkduy/plugin-kdu
yarn add @nkduy/plugin-kdu
bun add @nkduy/plugin-kdu
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-01-22 |
| First published | 2022-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 3.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | NKDuy |
| Maintainers | nkduy |

## Links

- npm: https://www.npmjs.com/package/@nkduy/plugin-kdu
- Repository: https://github.com/khanhduy1407/plugin-kdu
- Issues: https://github.com/khanhduy1407/plugin-kdu/issues
- npm.io page: https://npm.io/package/@nkduy/plugin-kdu

## Recent versions

- 1.1.0 (latest) — 2022-01-22

## README

# @nkduy/plugin-kdu

Note: requires `@kdu/compiler-sfc` as peer dependency. This is largely a port of `rollup-plugin-kdu` with some vite-specific tweaks.

```js
// vite.config.js
import kdu from '@nkduy/plugin-kdu'

export default {
  plugins: [kdu()]
}
```

## Options

```ts
export interface Options {
  include?: string | RegExp | (string | RegExp)[]
  exclude?: string | RegExp | (string | RegExp)[]

  ssr?: boolean
  isProduction?: boolean

  // options to pass on to @nkduy/compiler-sfc
  script?: Partial<SFCScriptCompileOptions>
  template?: Partial<SFCTemplateCompileOptions>
  style?: Partial<SFCStyleCompileOptions>
}
```

## Example for passing options to `@nkduy/compiler-dom`:

```ts
import kdu from '@nkduy/plugin-kdu'

export default {
  plugins: [
    kdu({
      template: {
        compilerOptions: {
          // ...
        }
      }
    })
  ]
}
```

## Example for transforming custom blocks

```ts
import kdu from '@nkduy/plugin-kdu'

const kduI18nPlugin = {
  name: 'kdu-i18n',
  transform(code, id) {
    if (!/kdu&type=i18n/.test(id)) {
      return
    }
    if (/\.ya?ml$/.test(id)) {
      code = JSON.stringify(require('js-yaml').safeLoad(code.trim()))
    }
    return `export default Comp => {
      Comp.i18n = ${code}
    }`
  }
}

export default {
  plugins: [kdu(), kduI18nPlugin]
}
```

## License

MIT

---
_Source: https://npm.io/package/@nkduy/plugin-kdu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
