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

使用cnpm安装包后,按需加载style文件,生成的style路径错误 #39

Closed
runtop opened this issue Sep 9, 2021 · 3 comments

Comments

@runtop
Copy link

runtop commented Sep 9, 2021

使用cnpm安装包,会在node_modules目录下生成带下划线前缀的目录,比如 :
node_modules\_vant@3.2.2@vant\lib\

在计算包路径时候 lastIndex 会导致多计算一个下划线字符

function resolveNodeModules(libName, ...dir) {
  const modulePath = require.resolve(libName);
  const lastIndex = modulePath.indexOf(libName);
 // console.log('resolveNodeModules', modulePath, lastIndex)
  return _vite.normalizePath.call(void 0, _path2.default.resolve(modulePath.substring(0, lastIndex), ...dir));
}

计算获取的路径为:
/node_modules/_/vant/es/icon/style

最终导致加载的style文件失败

@shinchanZ
Copy link

你好,请问这个最后怎么解决的,改源码吗

@runtop
Copy link
Author

runtop commented Oct 8, 2021

是的

@anncwb
Copy link
Collaborator

anncwb commented Nov 2, 2021

Try to upgrade to 1.3.0

@anncwb anncwb closed this as completed Nov 25, 2021
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