nuxt-alias-path

2.0.0 • Public • Published

nuxt-alias-path

npm version Linux macOS Windows compatible Build status Coverage status Dependency status Renovate enabled
Open in Gitpod Buy Me a Coffee PayPal Patreon

Cross-platform builds a path for nuxt.options.alias in modules. Passing a path straight away causes issues on Windows.

When you just write nuxt.options.alias['#foo'] = path in your Nuxt module, the dev server will not work on Windows. This module is a helper that fixes the issue and will hopefully eventually be fixed in Nuxt.

See here some modules also having the issue:

Install

# npm
$ npm install nuxt-alias-path

# Yarn
$ yarn add nuxt-alias-path

Usage

import nuxtAliasPath from 'nuxt-alias-path'
import { addTemplate } from '@nuxt/kit'

export default defineNuxtModule((options, nuxt) => {
  addTemplate({
    filename: 'mod.mjs',
    getContents: () => "export default { foo: 'bar' }",
    write: true,
  })
  nuxt.options.alias['#mod'] = nuxtAliasPath('mod.mjs', JSON.stringify(options))
})

Then use the alias somewhere else:

import foo from '#mod'

Contribute

Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️

Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

Buy Me a Coffee  If you want to send me a one time donation. The coffee is pretty good 😊.
PayPal  Also for one time donations if you like PayPal.
Patreon  Here you can support me regularly, which is great so I can steadily work on projects.

Thanks a lot for your support! ❤️

License

MIT License © Sebastian Landwehr

Readme

Keywords

none

Package Sidebar

Install

npm i nuxt-alias-path

Weekly Downloads

1,002

Version

2.0.0

License

MIT

Unpacked Size

7.2 kB

Total Files

4

Last publish

Collaborators

  • dword-design