next.config.js这样设置next-pwa和app实验。
const withPWA = require('next-pwa');
module.exports = withPWA({
pwa: {
dest: 'public',
disable: process.env.NODE_ENV === 'development'
},
experimental: {
appDir: true
},
});
错误:Error: > The
appdirectory is experimental. To enable, add
appDir: trueto your
next.config.jsconfiguration under
experimental. See https://nextjs.org/docs/messages/experimental-app-dir-config
尝试一个新创建的项目,确保配置应该工作
我无法让它运行,因为PWA包内的一些编译器错误(我假设它还不支持v13),但问题是你在PWA配置中定义experimental
,而不是在next.config.js
,
const withPWA = require("next-pwa")({
pwa: {
dest: "public",
disable: process.env.NODE_ENV === "development",
},
});
/** @type {import('next').NextConfig} */
const nextConfig = withPWA({
experimental: {
appDir: true,
},
});
module.exports = nextConfig;
这是一个很好的GH问题:https://github.com/vercel/next.js/issues/39161