Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
213 stars 13 forks source link

Issue adding vite-aliases to new project #47

Closed richard-edwards closed 1 year ago

richard-edwards commented 1 year ago
error when starting dev server:
TypeError: config2.resolve.alias is not iterable
    at config (file:///home/richard/Projects/vue-vite-test/vue-project/node_modules/vite-aliases/dist/index.js:273:91)
    at runConfigHook (file:///home/richard/Projects/vue-vite-test/vue-project/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62870:31)
    at resolveConfig (file:///home/richard/Projects/vue-vite-test/vue-project/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62379:20)
    at async createServer (file:///home/richard/Projects/vue-vite-test/vue-project/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:61641:20)
    at async CAC.<anonymous> (file:///home/richard/Projects/vue-vite-test/vue-project/node_modules/vite/dist/node/cli.js:707:24)
error Command failed with exit code 1.

Steps to reproduce

npm init vue@latest

Project name : vue-project
Typescript: yes
JSX: no
Router: yes
Pinia: yes
Vitest: yes
EtoE: Playright
<enter>
cd vue-project
yarn or (npm install)
yarn dev or (npm run dev)

Site runs fine

Add vite-aliases

yarn add vite-aliaes -D

Edit vite.config.ts

Add import { ViteAliases } from "vite-aliases"

and add to plugins

export default {
    plugins: [
        ViteAliases()
    ]
};

Run yarn dev and you will see the error

Subwaytime commented 1 year ago

Hey there! Thanks for the report :100: , have you tried adding

"type":"module"

to your package.json?

richard-edwards commented 1 year ago

Yes, forgot to mention that. Already added that as I saw it on another thread.

On Tue, 29 Nov 2022 at 07:51, Leon L. @.***> wrote:

Hey there! Thanks for the report, have you tried adding

"type":"module"

to your package.json?

— Reply to this email directly, view it on GitHub https://github.com/Subwaytime/vite-aliases/issues/47#issuecomment-1330606128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADXRROB2GFW7DWRAWRD6YLWKX34PANCNFSM6AAAAAASNVOS2A . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards,

Richard Edwards

Subwaytime commented 1 year ago

It seems that this will be fixed in the upcoming new version! Probably will be released on next weekend, atm i am a bit busy! So no promises :sweat_smile:

richard-edwards commented 1 year ago

My project has waited 3 years so far so that is good enough for me :) Thanks for the update!

Subwaytime commented 1 year ago

@richard-edwards Hey there! So i got an fix in the pipeline, which i will deploy after Christmas or starting next Year! I found out what the issue is basically, vite-aliases is trying to combine your existing aliases from the vite config with the generated ones. The issue here beeing, if you set resolve.alias as an object inside the vite.config.ts/js it wont work, but it will work with an array till the fix is ready, so hopefully thats a workaround for now!

richard-edwards commented 1 year ago

Awesome, thanks for the update!

On Thu, 22 Dec 2022 at 15:02, Leon L. @.***> wrote:

@richard-edwards https://github.com/richard-edwards Hey there! So i got an fix in the pipeline, which i will deploy after Christmas or starting next Year! I found out what the issue is basically, vite-aliases is trying to combine your existing aliases from the vite config with the generated ones. The issue here beeing, if you set resolve.alias as an object inside the vite.config.ts/js it wont work, but it will work with an array till the fix is ready, so hopefully thats a workaround for now!

— Reply to this email directly, view it on GitHub https://github.com/Subwaytime/vite-aliases/issues/47#issuecomment-1363292213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADXRRPPLMTND7HPLLUXIR3WOSXTVANCNFSM6AAAAAASNVOS2A . You are receiving this because you were mentioned.Message ID: @.***>

-- Regards,

Richard Edwards