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

当引入node_modules/@XX开头的文件,会默认走到src/@XX #48

Open
czj986399434 opened this issue Aug 20, 2023 · 0 comments
Open

Comments

@czj986399434
Copy link

如果在node_modules中的插件是以@开头,导入就会有问题

如果我需要引入node_modules中的 @aa/plugin插件
/node_modules/@aa/plugin
const context = require.context('@aa/plugin'),会默认去到src/@aa/plugin。

建议先加载vite.config.ts中的resolve.alias,让用户自由配置从哪导入的模块:

export default ({mode})=>{
     return defineConfig({
         resolve: {
                alias: [
                    {
                        find:'@aa',
                        replacement:resolve(__dirname, 'node_modules/@aa'),
                    
                    },
                    {
                        find:'@',
                        replacement:resolve(__dirname, 'src'),
                    },
                ],
          },`
    })
}

欢迎大大们解答

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

1 participant