r-yongkuk / nuxt-lodash

Lodash module for Nuxt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lodash for Nuxt

Version License Types

πŸ’‘ About

Lodash auto-import module for Nuxt.

πŸ“¦ Install

  1. Install nuxt-lodash as development dependency:
npm i nuxt-lodash -D
  1. Add it to the modules section of your nuxt.config:
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-lodash']
})

πŸš€ Example

Use any Lodash methods in your Nuxt application, they will be auto-imported!

<script setup>
const text = useToUpper('it works!');
</script>

<template>
  <div>{{ text }}</div>
</template>

πŸ”¨ Config

Name Default Description
prefix 'use' String to prepend before each Lodash function (false to disable)
prefixSkip ['is'] Functions that starts with keywords in this array will be skipped by prefix
exclude [] Array of Lodash functions to exclude from auto-imports
alias [] Array of array pairs to rename specific Lodash functions (prefix is still added)

πŸ’» Example - Config

import { defineNuxtConfig } from 'nuxt';

export default defineNuxtConfig({
  modules: ['nuxt-lodash'],
  lodash: {
    prefix: 'use',
    prefixSkip: ['is'],
    exclude: ['map'],
    alias: [
      ['camelCase', 'stringToCamelCase'], // => useStringToCamelCase
      ['kebabCase', 'stringToKebabCase'], // => useStringToKebabCase
    ]
  }
});

πŸ“„ License

MIT License © 2021-2022 - Michal Čípa

About

Lodash module for Nuxt

License:MIT License


Languages

Language:TypeScript 95.8%Language:Vue 4.2%