Lodash for Nuxt
๐ก About
Lodash auto-import module for Nuxt.
๐ฆ Install
- Install
nuxt-lodash
as development dependency:
npm i nuxt-lodash -D
- Add it to the
modules
section of yournuxt.config
:
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 this keywords will be skipped by prefix (false to disable) |
upperAfterPrefix | true | If true it will automatically uppercase first letter after prefix (false to disable) |
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
export default defineNuxtConfig({ modules: ["nuxt-lodash"], lodash: { prefix: "_", prefixSkip: ["string"], upperAfterPrefix: false, exclude: ["map"], alias: [ ["camelCase", "stringToCamelCase"], // => stringToCamelCase ["kebabCase", "stringToKebab"], // => stringToKebab ["isDate", "isLodashDate"], // => _isLodashDate ], },});
๐ License
MIT License ยฉ 2021-2022 - Michal ฤรญpa