Answer the question
In order to leave comments, you need to log in
How to properly set font paths in webpack when converting scss to css?
Project structure:
src/
├── fonts/
├── js/
├── images/
└── sass/
@font-face {
font-family: 'Geometria';
src: local('Geometria Thin'), local('Geometria-Thin'),
url('../fonts/Geometria-Thin.woff') format('woff');
font-weight: 100;
font-style: normal;
}
{
test: /\.(?:|woff)$/,
use: [
{
loader: 'file-loader',
options: {
name: `./fonts/[name].[ext]`,
}
}
]
}
plugins: [
new MiniCssExtractPlugin({
filename: `./css/${filename('css')}`
}),
],
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {}
}, 'css-loader', 'sass-loader'],
}
]
}
Answer the question
In order to leave comments, you need to log in
Found a solution, you need to add a publicPath that will be substituted for the url
use: [
{
loader: 'file-loader',
options: {
name: `fonts/[name].[ext]`,
publicPath: "../",
}
}
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question