rohanray / next-fonts

Import fonts in Next.js (supports woff, woff2, eot, ttf, otf & svg)
179 stars 12 forks source link

Make the package compatible with webpack 5 #37

Closed kachkaev closed 3 years ago

kachkaev commented 3 years ago

After adding "webpack": "^5.4.0" to package.jsonresolutions in one of my Next.js projects as advised, I saw this error in the build output:

> Build error occurred
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration[0].module.rules[3].issuer has an unknown property 'test'. These properties are valid:
   object { and?, not?, or? }
 - configuration[1].module.rules[3].issuer has an unknown property 'test'. These properties are valid:
   object { and?, not?, or? }
    at validate (/Users/ak/-/projects/emi-penza/website/node_modules/webpack/node_modules/schema-utils/dist/validate.js:104:11)
    at validateSchema (/Users/ak/-/projects/emi-penza/website/node_modules/webpack/lib/validateSchema.js:73:2)
    at create (/Users/ak/-/projects/emi-penza/website/node_modules/webpack/lib/webpack.js:102:3)
    at webpack (/Users/ak/-/projects/emi-penza/website/node_modules/webpack/lib/webpack.js:139:31)

The origin was next-fonts and the issue ended up being quite easily fixable. See Rule.issuer docs

PS: I'm aware of #34 but I still find this package useful. It helps keep fonts next to a file with the global styles. I also don't have to worry about keeping too many files with all sorts of font-faces and using only a couple of them (only the ones mentioned in url will end up in the prod container). Finally, because of name: [name]-[hash].[ext], I don't have to worry about cache invalidation myself.

It'd be great if you could release a patch and maintain the project in general. Thanks for your effort on creating it in the first place! 👍

rohanray commented 3 years ago

Thank you very much @kachkaev for the contribution! I have published v 1.5.0 with your PR. Please let me know if it works fine.

Also, I have released v 1.5.1 with upgraded deps of file-loader and url-loaded versions. I would really appreciate if you can share your feedback on using v 1.5.1.

Thanks -RR