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

Does not work with resolve.alias #3

Closed
maksimsemenov opened this issue Feb 26, 2021 · 4 comments
Closed

Does not work with resolve.alias #3

maksimsemenov opened this issue Feb 26, 2021 · 4 comments

Comments

@maksimsemenov
Copy link

When I'm trying to use vite-plugin-solid with vite config resolve.alias property, the aliases are not replaced.

// vite.config.js

import { defineConfig } from 'vite'
import solidPlugin from 'vite-plugin-solid'

export default defineConfig({
  resolve: {
    alias: {
      views: './src/views',
    }
  },
  // plugins: [solidPlugin()],
  server: {
    port: 1234
  }
})
// index.tsx

import { render } from 'solid-js/web'
import { Root } from 'views/App/Root'

render(() => <Root />, document.getElementById('app'))

Then, when I try to start vite server, I'm getting an error:

Error: The following dependencies are imported but could not be resolved: views/App/Root 

If I disable the plugin, vite will start the server

@amoutonbrady
Copy link
Member

This is has been released in version 1.2.3

@utherpally
Copy link

@amoutonbrady
This work:

...
resolve: {
    alias: [
      { find: 'views', replacement: './src/views' },
    ]
  },
...

But this don't work:

...
resolve: {
    alias: {
      views: './src/views',
    }
  },
...
``

@amoutonbrady amoutonbrady reopened this Mar 19, 2021
@amoutonbrady
Copy link
Member

Ah, I see.. that's an odd syntax.. I used a package that automatically handles deep merging but I guess it gets stuck on trying to merge an object into an array. I guess I'll have to do a bit of a manual work there.

Thanks for bringing that up to my attention :)

@amoutonbrady
Copy link
Member

@langbamit For what it's worth, top level alias is deprecated:

image

https://vitejs.dev/config/#resolve-alias

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