I have the following Webpack configuration (roughly speaking, it has been simplified for this post):
const rootPublic = path.resolve('./public'); const LOCAL_IDENT_NAME = 'localIdentName=[name]_[local]_[hash:base64:5]'; const CSS_LOADER = `css?sourceMap&${LOCAL_IDENT_NAME}&root=${rootPublic}`; const SASS_LOADER = 'sass?sourceMap&includePaths[]=' + path.resolve(__dirname, './src/styles'); // ... loaders: loaders: [ { test: /\.(jpe?g|png|gif|svg)$/, loader: 'url-loader?limit=10000&name=[path][name].[ext]' }, { test: /\.scss$/, loader: config.DEVELOPMENT_MODE ? `style!${CSS_LOADER}!autoprefixer!${SASS_LOADER}` : ExtractTextPlugin.extract('style', `${CSS_LOADER}!autoprefixer!${SASS_LOADER}`) }, // ... ]
Now this works fine for images that are usually referenced by scss files:
.some-static-class { background: url('/images/bg.png'); }
However, when using the :local directive :local it does not work:
:local .SomeClass { background: url('/images/bg.png'); }
And I think that since root defined for the CSS loader. I get a build error: Module not found: Error: Cannot resolve 'file' or 'directory' ./../../../../../../../../images/bg.gif
If instead I remove root from the css-loader configuration, then it builds fine, but then the path "looks" correct in the Chrome inspector, but when you really open the link in a new tab, it points to: chrome-devtools://devtools/bundled/"/images/bg.png" , which obviously does not resolve correctly.
I am not sure if the url-loader configuration problem or what exactly happens.
I played with various webpack configurations to specify resol.root, resolve.modulesDirectories, etc., but am completely not sure if they have any effect, or if I'm just wrong. I also met resolve-url-loader , but not sure if this is even what I need at all.
Any ideas? MTIA!
UPDATE
I should note that it works fine in Safari, but not in Chrome. So this seems like a bug specific to Chrome, but it is not practical to do all of our development in Safari.
I also stumbled upon vue-style-loader , which is a downloader style fork that claims to fix this problem, but fixes this by relying on a hacker -style outdated escape / unescape method.