Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving nuxt specific aliases in storybook #8

Closed
deanc opened this issue Dec 9, 2022 · 1 comment
Closed

Resolving nuxt specific aliases in storybook #8

deanc opened this issue Dec 9, 2022 · 1 comment

Comments

@deanc
Copy link

deanc commented Dec 9, 2022

I'm using import { useState } from '#app' in one component, so I added something like this, in vite.config.ts as storybook was complaining it couldn't resolve #app:

'#app': path.resolve(__dirname, './node_modules/nuxt/dist/app/index.mjs'),

Which then complained about not being able to resolve #head on THAT file, so I fixed that, and it complained about #build so it seems you'll end up down a rabbit hole here.

@ambroisemaupate
Copy link

Add following aliases to your vite.config.js|ts

resolve: {
    alias: {
        '~': path.resolve(__dirname),
        '#app': path.resolve(__dirname, 'node_modules/nuxt/dist/app'),
        '#head': path.resolve(__dirname, 'node_modules/nuxt/dist/head/runtime'),
        '#imports': path.resolve(__dirname, '.nuxt/imports'),
        '#components': path.resolve(__dirname, '.nuxt/components'),
        '#build': path.resolve(__dirname, '.nuxt'),
        '@': path.resolve(__dirname),
        '~~': path.resolve(__dirname),
        '@@': path.resolve(__dirname),
        assets: path.resolve(__dirname, '/assets'),
        public: path.resolve(__dirname, '/public')
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants