bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

Loader looking in /sys/kernel/slab/? #37

Closed LaurensBosscher closed 7 years ago

LaurensBosscher commented 7 years ago

Hi,

I've added the configuration to webpack as recommended:

config.module.loaders.push({
  test: /\.scss$/,
  loaders: ['style', 'css', 'resolve-url', 'sass?sourceMap'],
});

Installed resolve-url-loader, and ran with a sass file with an url in it. I keep running however into the following error:

webpack_1                | WARNING in /~/css-loader!/~/resolve-url-loader!/~/sass-loader?sourceMap!/scss/app.scss
webpack_1                |   resolve-url-loader cannot operate: CSS error
webpack_1                |   ENOENT: no such file or directory, scandir '/sys/kernel/slab/nf_conntrack_173/cgroup'
webpack_1                |   at Error (native)

It seems that resolve-url-loader is looking in /sys/kernel/slab/... for the linked files or am I reading this incorrect? Assuming that I didn't do anything stupid, how would I be able to further debug this issue?

bholloway commented 7 years ago

@LaurensBosscher Sorry for the delay in responding.

It looks like the search is escaping from the project directory because it cannot find the file.

Speculation

The project directory is assumed to be the current working directory in which your build is invoked. If you have a Webpack root defined then that is used instead.

Do you have .scss files that are outside of the working directory. Maybe because of npm link?

Debugging

Sorry I should have added a verbose option ages ago.

In the absence of that, put a console.log(pathToRoot) just before this line of code.

That pathToRoot Array should have the list of directories to the root. If your root does not include your project directory you will have problems.

LaurensBosscher commented 7 years ago

Ah, that makes a lot of sense! Turns out that due to a configuration error the build was running in the root of my docker image. After moving everything to its own directory, everything seems to work as expected.

Running everything in the root of the filesystem is really an extreme edge case but it might be useful to add the search order and debug information to the documentation. I found it quite helpful.

Thanks!