Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update next v14 #434

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nextPWA from '@ducanh2912/next-pwa';
arvinxx marked this conversation as resolved.
Show resolved Hide resolved
import analyzer from '@next/bundle-analyzer';
import nextPWA from 'next-pwa';

const isProd = process.env.NODE_ENV === 'production';
const buildWithDocker = process.env.DOCKER === 'true';
Expand All @@ -11,55 +11,64 @@ const withBundleAnalyzer = analyzer({
const withPWA = nextPWA({
dest: 'public',
register: true,
skipWaiting: true,
workboxOptions: {
skipWaiting: true,
},
});

/** @type {import('next').NextConfig} */
const nextConfig = {
compress: isProd,
reactStrictMode: true,
env: {
AGENTS_INDEX_URL: process.env.AGENTS_INDEX_URL ?? '',
PLUGINS_INDEX_URL: process.env.PLUGINS_INDEX_URL ?? '',
},
experimental: {
forceSwcTransforms: true,
optimizePackageImports: [
'modern-screenshot',
'emoji-mart',
'@emoji-mart/react',
'@emoji-mart/data',
'@icons-pack/react-simple-icons',
'gpt-tokenizer',
'chroma-js',
],
webVitalsAttribution: ['CLS', 'LCP'],
},
images: {
unoptimized: !isProd,
remotePatterns: [
{
protocol: 'https',
hostname: 'registry.npmmirror.com',
port: '',
pathname: '/@lobehub/assets-emoji/1.3.0/files/assets/**',
port: '',
protocol: 'https',
},
{
protocol: 'https',
hostname: 'registry.npmmirror.com',
port: '',
pathname: '/@lobehub/assets-emoji-anim/1.0.0/files/assets/**',
port: '',
protocol: 'https',
},
{
protocol: 'https',
hostname: 'registry.npmmirror.com',
port: '',
pathname: '/@lobehub/assets-logo/1.1.0/files/assets/**',
port: '',
protocol: 'https',
},
{
protocol: 'https',
hostname: 'registry.npmmirror.com',
port: '',
pathname: '/@lobehub/assets-favicons/latest/files/assets/**',
port: '',
protocol: 'https',
},
],
unoptimized: !isProd,
},
experimental: {
webVitalsAttribution: ['CLS', 'LCP'],
forceSwcTransforms: true,
optimizePackageImports: [
'modern-screenshot',
'emoji-mart',
'@emoji-mart/react',
'@emoji-mart/data',
'@icons-pack/react-simple-icons',
'gpt-tokenizer',
'chroma-js',
],
},
output: buildWithDocker ? 'standalone' : undefined,

reactStrictMode: true,

transpilePackages: ['@lobehub/ui', 'antd-style', 'lodash-es'],

webpack(config) {
Expand All @@ -68,15 +77,10 @@ const nextConfig = {
layers: true,
};

return config;
},
config.resolve.alias['@ant-design/cssinjs'] = '@ant-design/cssinjs/lib';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an awsome idea! I have tried with transpilePackages but find it not working correctly. πŸ˜…

cc @MadCcc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

666


env: {
AGENTS_INDEX_URL: process.env.AGENTS_INDEX_URL,
PLUGINS_INDEX_URL: process.env.PLUGINS_INDEX_URL,
return config;
},

output: buildWithDocker ? 'standalone' : undefined,
};

export default isProd ? withBundleAnalyzer(withPWA(nextConfig)) : nextConfig;
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"lucide-react": "latest",
"modern-screenshot": "^4",
"nanoid": "^5",
"next": "^13.5.3",
"next": "^14.0.1",
"openai": "~4.15.0",
"polished": "^4",
"posthog-js": "^1",
Expand Down Expand Up @@ -121,10 +121,11 @@
},
"devDependencies": {
"@commitlint/cli": "^18",
"@ducanh2912/next-pwa": "^9.7.2",
"@lobehub/i18n-cli": "latest",
"@lobehub/lint": "latest",
"@next/bundle-analyzer": "^13",
"@next/eslint-plugin-next": "^13",
"@next/bundle-analyzer": "^14.0.1",
"@next/eslint-plugin-next": "^14.0.1",
"@testing-library/jest-dom": "^6",
"@testing-library/react": "^14",
"@types/chroma-js": "^2",
Expand All @@ -148,7 +149,6 @@
"lint-staged": "^15",
"lodash": "^4",
"markdown-table": "^3",
"next-pwa": "^5",
"node-fetch": "^3",
"prettier": "^3",
"remark-cli": "^11",
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
const lang = cookieStore.get(LOBE_LOCALE_COOKIE);

return (
<html lang={lang?.value || DEFAULT_LANG}>
<html lang={lang?.value || DEFAULT_LANG} suppressHydrationWarning>
<body>
<StyleRegistry>
<Layout
Expand Down