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

Customizing the auto-import path #2554

Open
1 task done
Ena-Heleneto opened this issue Jun 21, 2024 · 3 comments
Open
1 task done

Customizing the auto-import path #2554

Ena-Heleneto opened this issue Jun 21, 2024 · 3 comments

Comments

@Ena-Heleneto
Copy link

Ena-Heleneto commented Jun 21, 2024

Describe the feature

I want to optimize the code structure, not all of it is in untils. Can this be achieved through configuration?

Additional information

  • Would you be willing to help implement this feature?
@MickL
Copy link
Contributor

MickL commented Jun 22, 2024

I am not sure if I understand your question. Do you want to add other folders that are auto imported? If yes, this is from the Nuxt docs:

You can also auto-import functions exported from custom folders or third-party packages by configuring the imports section of your nuxt.config file.

Same should apply to nitro.config.ts

@Ena-Heleneto
Copy link
Author

First of all, thank you for your reply, but I still have some questions

This is my project structure
image

I want to automatically import modules in server/services

In nuxt.config.ts, I can set the frontend module path for auto-import via imports, but this is not available for backend modules

  // `stores` Frontend module path
  // `services` Backend module path
  // I tried this way of writing, and it didn't work either.  dirs: ['stores', 'server/services'],
  imports: {
    imports: [
      { name: 'consola', from: 'consola' },
      { name: '*', from: 'echarts', as: 'eCharts' },
      { name: '*', from: 'bpmn-js', as: 'bpmn' },
      { name: '*', from: 'esdk-obs-nodejs', as: 'obs' },
    ],
    dirs: ['stores', 'services'],
  },

Do I need to configure it separately in nitro?

Thanks

@Ena-Heleneto
Copy link
Author

Hello,Can someone help me?

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

No branches or pull requests

2 participants