My project file structure:
- dist
- src
- assets
- fonts
webpack.config.js
I have the following webpack config entry for file loader:
context: path.join(__dirname, 'src'),
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: '[name].js'
},
{
test: /\.(woff|woff2)(\?v=[0-9]\.[0-9])?$/,
exclude: /node_modules/,
loader: 'file-loader'
}
And my scss file references the font file:
@font-face {
font-family: 'Interface';
font-style: normal;
font-weight: 400;
src: url("/assets/fonts/Interface-Regular.woff2?v=1.6") format("woff2"),
url("/assets/fonts/Interface-Regular.woff?v=1.6") format("woff");
}
If I go to localhost:{port}/webpack-dev-server the font files are not there. The output from webpack-dev-server also doesn't show anything related to my font files.
Isn't file-loader supposed to provide a copy of the font files to webpack?