TypeError: content.match is not a function
Using
npm: 8.4.0
webpack: 5.52.1
fontmin-webpack: 3.2.0
I set up FontminPlugin in my webpack project as per its documentation (following reduced to minimal setup):
const FontminPlugin = require('fontmin-webpack');
module.exports = {
entry: 'my-entry.js',
output: {
// ...
},
plugins: [
// ...
new FontminPlugin({
autodetect: true
})
],
}
I get the following TypeError when running my webpack build:
$ npm run build
> [email protected] build
> webpack
myproject/node_modules/fontmin-webpack/lib/index.js:117
const matches = content.match(GLYPH_REGEX) || []
^
TypeError: content.match is not a function
at myproject/node_modules/fontmin-webpack/lib/index.js:117:33
at arrayMap (myproject/node_modules/lodash/lodash.js:653:23)
at Function.map (myproject/node_modules/lodash/lodash.js:9622:14)
at interceptor (myproject/node_modules/lodash/lodash.js:17094:35)
at Function.thru (myproject/node_modules/lodash/lodash.js:8859:14)
at myproject/node_modules/lodash/lodash.js:4430:28
at arrayReduce (myproject/node_modules/lodash/lodash.js:697:21)
at baseWrapperValue (myproject/node_modules/lodash/lodash.js:4429:14)
at LodashWrapper.wrapperValue (myproject/node_modules/lodash/lodash.js:9114:14)
at FontminPlugin.findUnicodeGlyphs (myproject/node_modules/fontmin-webpack/lib/index.js:138:8)
Thanks for filing @Abdull! Would you mind sharing what's in your // ... and entry file?
Our test cases look exactly like our readme and are passing on webpack 5, so I suspect interplay with another plugin or content type.
I had this issue using another plugin MiniCssExtractPlugin.
My solution was to put the Fontmin-Webpack plugin before MiniCssExtractPlugin and it disappeared.
ENV: using the Asset Modules and no file-loader, with [email protected], [email protected]