I am using Webpack 2 and the webpack-dev server along with the Sass bootloader, the actual configuration:
{ test: /\.scss/, loaders: [ "style", { loader: "css", query: { modules: false, sourceMap: true } }, { loader: "resolve-url" }, { loader: "sass", query: { sourceMap: true } } ] }
This works very well, and the image specified in background: url() is processed by webpack and also replaced in the style for something like background-somehash.jpg , this file can be accessed by typing http://localhost:8080/background-somehash.jpg . It also works when I provide the whole url (including localhost) in the style background definition using developer tools ...
The only thing that doesn't work is the original css created by webpack, which looks like background: url(background-somehash.jpg) . I also tried various URLs like ./ , ../ , ../../ or ./images/ to check if root was installed somehow differently. I do not understand that the file is easily accessible in the root ...
EDIT: When used with extract-text-webpack-plugin , which extracts styles into a separate real styles.css file, it works fine. The question is why this does not work when the last css is served from a javascript package?
CLARIFICATION: Everything is correctly indicated, the image is available, everything works when I extract css to a separate file using extract-text-webpack-plugin , it just does not work when completely the same css is served from bundle.js , which then refers to index.html for example <link href="blob:..." rel="stylesheet">
source share