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

import路径的计算似乎有些没有覆盖的场景 #6

Open
otakustay opened this issue Apr 18, 2018 · 1 comment
Open

import路径的计算似乎有些没有覆盖的场景 #6

otakustay opened this issue Apr 18, 2018 · 1 comment

Comments

@otakustay
Copy link

假设我们的结构是这样的:

/src <-- context
  /styles
    variables.less <-- pattern
  /components
    /FooBar
      /index.less <-- use
/node_modules
  /reset-less
    index.less

/src作为context,将/src/styles/variables.less作为被style-resources-loader处理的文件。在variables.less中写这样的代码:

@import "reset-less/index.less";

此时这个@import语句会被loader的逻辑修改为:../node_modules/reset-less/index.less

这导致在/src/components/FooBar/index.less中多出了@import "../node_modules/reset-less/index.less";这样一条语句,显然这是不可能找到正确的文件的

@otakustay
Copy link
Author

这里可能有几个细节:

  1. 如何区分绝对的引用和相对的引用,这在less中和在js中并不相同,是不是干脆把路径交给webpack去resolve,而不要自己在文件系统上计算?
  2. less-loaderpaths配置,这个配置存在的情况下会取消webpack的路径查找功能,此处有可能存在一些兼容性问题

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