Currently, I am using webpack via CLI with a command like webpack --watch
. My objective is to compile JavaScript with SASS and place it in a separate HTML page.
Within my SASS, I have links to SVG files that look like this:
label {
background: url(../images/checkbox.svg);
}
However, I am facing an issue where the compiled CSS does not display in the browser after compilation. This has led to various situations:
- When I compile using svg-loader, the compiled CSS in the browser shows
background: url([object Object]);
A suggestion has been made to use svg-url-loader
instead.
- If I use the recommended
svg-url-loader
, the entire page's CSS gets disrupted, causing the browser to display raw text instead of styled content. - When utilizing
file-loader
, the CSS is compiled to
. This poses a challenge as I do not want to copy files I already have when moving the resulting bundle.js elsewhere.background: url(37efc0ccedf6fe109636ad1416c29425.svg)
- Trying
raw-loader
results in displaying XML instead of a file name in the URL(...), leading to a "wrong property value" error in the CSS. Ideally, I would like to have a regular path displayed instead, likebackground: url(../images/checkbox.svg);
Therefore, I am seeking guidance on the correct approach to handle SVG files in my specific scenario. Any help would be greatly appreciated. Thank you.