Unable to resolve module error and reproduction of issue · Issue #109 · webpack-contrib/less-loader (original) (raw)
I've run into a bunch of issues attempting to use @import
and url()
when adding CSS modules to a current project and using less-loader
.
It looks like a lot of people have this error:
- less-loader is trying to resolve url references relative to the starting point(root less file) instead of using the current file #76 (same issue?)
- @import "~aptr-uikit/scr/index.less"; not working #101
- import with absolute paths #93
- problem with resolve relative path witch LESS function #85 (connected issue?)
... and so on.
I absolutely cannot get any kind of relative file load to work. I've attempted to create a minimal reproducible test case for the issue. The repository is located here: https://github.com/jsonnull/less-modules-resolve.
npm install
and npm run build
to see the issue.
ERROR in ./~/css-loader?modules!./~/less-loader?sourceMap!./src/index.less
Module not found: Error: Can't resolve 'material-design-icons/MaterialIcons-Regular.ttf' in '/Users/jsonnull/less-modules-resolve/src'
@ ./~/css-loader?modules!./~/less-loader?sourceMap!./src/index.less 6:470-528
@ ./src/index.less
@ ./src/index.js
See below, the file is clearly present:
├── dist
│ └── build.js
├── npm-debug.log
├── package.json
├── src
│ ├── index.js
│ ├── index.less
│ └── material-design-icons
│ ├── LICENSE
│ ├── MaterialIcons-Regular.eot
│ ├── MaterialIcons-Regular.ijmap
│ ├── MaterialIcons-Regular.svg
│ ├── MaterialIcons-Regular.ttf
│ ├── MaterialIcons-Regular.woff
│ ├── MaterialIcons-Regular.woff2
│ ├── README.md
│ ├── codepoints
│ └── material-icons.less
└── webpack.config.js
I've tried every combination for the less file import as well as the url()
import I can think of...
file
- I think this one should work?./file
- I think this one should definitely work~file
- I think this one should not work/file
- I think this one should not work
And, anyways, none of these methods work.
Assuming this is possible, how can the repository above be fixed so that all issues are resolved using the current directory structure? Otherwise, are there really combinations of relative paths that are completely impossible to use for importing?
From scrounging through issues it really does seem like nobody has a clear understanding of what this issue is or how to fix it. If we can come up with a clear answer for this issue for why it doesn't work and how to fix, hopefully others can learn from this and we can come up with good documentation for how to avoid this issue.