Closed ljosberinn closed 3 years ago
Hey @ljosberinn
Would you be able to provide a repro?
What version of preact do you have installed?
Did you try to conditionally apply this plugin? Something along these lines should allow you to:
(config, options) => {
if (!options.dev) {
return withPreact()(config);
}
}
Closing as this is currently not a focus for the plugin
Ran into this issue myself, you can add preact's devtools by adding the following to next.config.js
//next.config.js
const nextConfig = {
// ...
webpack(config, { dev, isServer }) {
config = preactModifications({ config, dev, isServer })
return config
},
}
function preactModifications({ config, dev, isServer }) {
// inject Preact DevTools
if (dev && !isServer) {
const entry = config.entry;
config.entry = () =>
entry().then((entries) => {
entries["main.js"] = ["preact/debug"].concat(entries["main.js"] || []);
return entries;
});
}
return config;
}
Hi,
I've been trying for a while now to use React in dev and Preact only in prod with React 17 but sadly to no avail. This is solely because I prefer the react devtools by far over the Preact devtools. However, with React 17 I'm not getting beyond this error when building:
Since it's included in
preact/compat
, I figured I could just add it to the existing aliases:leading to the same error.
Anyways, this is the entire fn I'm applying in
next.config.js
currently:which works fine in dev, but not in prod, clearly, so I'm locked to 16.14.0 atm.
Considering there's a bit more going on in the plugin here and abstracting this topic away seems like a good idea in general:
withPreact
from the plugin enabling that behaviour conditionally? could just bewithPreact({ ...defaultConfig, preactEnabled: bool }, options })
defaulting to true