In my fonts.scss
source file (same result if this is a pure CSS import)
@font-face {
font-family: "SocialIcons";
src: url("../fonts/social-icons.woff") format("woff");
font-weight: normal;
font-style: normal;
font-display: block;
}
After npm run build
which runs webpack, it's rendered as this:
@font-face {
font-family: "SocialIcons";
src: url([object Object]) format("woff");
font-weight: normal;
font-style: normal;
font-display: block;
}
So the file path is broken, rendering as [object Object]
rather than the path to the file.
It's a Roots Sage 9.0.10 theme for WordPress, using webpack
. Here are some key dependencies:
"css-loader": "^0.28.11",
"file-loader": "^6.2.0",
"node-sass": "^5.0.0",
"postcss-loader": "^4.0.4",
"postcss-safe-parser": "^5.0.2",
"resolve-url-loader": "^3.1.2",
"sass-loader": "~6.0",
"style-loader": "^0.23.1",
"url-loader": "^4.1.1",
"webpack": "~3.10.0",
The issue seems to be limited to relative paths. When I put in an absolute path, it is fine - ie. url(/wp-content/theme/resources/assets/fonts/social-icons.woff)
but this isn't great for production as I would like all references to be to the dist
directory.
Has anyone experienced this, and if so, was there a solution?