Next.js:对_app.tsx或_app.jsx进行更改不会更新站点,自定义pageExtensions设置

8xiog9wr  于 2023-05-17  发布在  其他
关注(0)|答案(1)|浏览(141)

我的pages/_app.tsx看起来像这样:

import type { AppProps } from "next/app";
import Head from "next/head";

import { MantineProvider } from "@mantine/core";

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <Head>
        <title>My title</title>
        <meta name="description" content="My description" />
        <link rel="icon" href="/favicon.png" />
      </Head>
      <MantineProvider
        withGlobalStyles
        withNormalizeCSS
      >
        <Component {...pageProps} />
      </MantineProvider>
    </>
  );
}

如果我运行开发服务器(npm run dev),那么一切都工作得很好。
问题是,如果我对my _app.tsx文件进行了更改,那么这些更改不会反映在正在运行的应用程序上。即使我故意插入错误并试图破坏网站,那么旧版本的_app.tsx仍然会被使用。
如果我构建应用程序,那么问题仍然存在。

noj0wjuj

noj0wjuj1#

我更改了应用程序的页面扩展名,我的next.config.js看起来像这样:

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  output: "standalone",
  pageExtensions: ["page.tsx", "page.ts", "page.jsx", "page.js"],
};

module.exports = nextConfig;

我只需要将_app.tsx重命名为_app.page.tsx

相关问题