Open Neojoke opened 6 months ago
根据 nextjs 的官方文档:https://nextjs.org/docs/pages/building-your-application/configuring/babel
还需要加入 "presets": ["next/babel"]
,可以解决这个问题:
{
"presets": ["next/babel"],
"plugins": []
}
但是,在 nextjs page router 运行时下会报出新的错误:
Global CSS cannot be imported from files other than your Custom <App>. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
还是请官方出一份 nextjs 接入方案为好。
Basic Info
Steps to reproduce
设置 .babelrc.js:module.exports = function (api) { api.cache(true);
}
tsconfig.json: { "compilerOptions": { "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "strict": false, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true, "baseUrl": "./src", "paths": { "@/": ["./"] }, "rootDirs": ["common/src/", "arco-design-pro-cra/src/", "arco-design-pro-next/src/"] }, "include": ["*/.ts", "*/.tsx"], "exclude": ["node_modules"] }