1.0.1 • Published 3 years ago
nuxt-unjs v1.0.1
Nuxt UnJS Module
UnJS is great and provides many amazing utilities! This module enables auto-import for their packages* in your Nuxt project.
* - Check map.ts for supported packages
📦 Get Started
- Install
nuxt-unjsas development dependency:
npm i nuxt-unjs -D- Add it to the
modulessection of yournuxt.config:
export default defineNuxtConfig({
modules: ['nuxt-unjs'],
});🚀 Example
<script setup>
const text = usePascalCase('foo-bar') // scule
const myObj = useDefu({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); // defu
useConsola.log(myObj); // consola
</script>
<template>
<div>{{ text }}</div>
</template>🔨 Config
export default defineNuxtConfig({
modules: ['nuxt-unjs'],
unjs: {
enable: true,
packages: [
'std-env',
'defu',
'destr',
'items-promise',
'scule',
'ufo',
'consola'
],
prefix: 'use',
},
});Note
If any packages are not found, you may need to add it to your dependencies like so:
npm i std-env defu -D💻 Development
- Run
npm run dev:prepareto generate type stubs. - Use
npm run devto start playground in development mode.
You can also run this on StackBlitz.