I'm developing an app using Preact. For context, here are my package.json scripts:
"scripts": {
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider preact build",
"serve": "sirv build --cors --single",
"dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider preact watch",
"lint": "eslint src",
"test": "jest"
},
It used to work like a charm using npm run dev. Today I attempted npm run build for the first time and encountered
WARN Failed to load preact-cli config file, using default!
Function.prototype.apply was called on undefined, which is a undefined and not a function
There is a preact.config.js file in the right directory, and it was detected in watch mode, but apparently in build mode it is not.
Worse, after messing around and reinstalling all dependencies, it doesn't work in watch mode anymore. I don't get a warning about the presence or absence of the preact.config.js file, but Preact suddenly can't parse otf files anymore, even though a loader for that is configured in preact.config.js, which seems to indicate again that that file isn't detected (why watch mode suddenly can't find it is a mystery).
Here is my preact.config.js:
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
export default function (config, env, helpers) {
// Add a new rule for .otf fonts
config.module.rules.push({
test: /\.otf$/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/',
publicPath: '/fonts/',
},
});
// Add an alias for 'phaser' to point to the non-ESM build
config.resolve.alias['phaser'] = path.resolve(__dirname, 'node_modules/phaser/dist/phaser.js');
config.resolve.alias['@legion/shared'] = path.resolve(__dirname, '../shared/');
let babelLoader = helpers.getLoadersByName(config, 'babel-loader')[0].rule;
babelLoader.exclude = /node_modules\/phaser/;
}
My preact-cli version is 3.5.0
Any hints as how I could resolve this?