Skip to content

Commit

Permalink
fix: SunEditor 관련 빌드 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yeolyi committed Feb 10, 2024
1 parent 9b8e52e commit 653ea0d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
5 changes: 1 addition & 4 deletions app/[locale]/community/news/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use client';

import { useRouter } from 'next/navigation';

import { revalidateNewsTag } from '@/actions/newsActions';
import { useRouter } from '@/navigation';

import { postNews } from '@/apis/news';

Expand Down
4 changes: 4 additions & 0 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { notFound } from 'next/navigation';
import { NextIntlClientProvider } from 'next-intl';
import { unstable_setRequestLocale } from 'next-intl/server';
import { ReactNode } from 'react';
import { Toaster } from 'react-hot-toast';

Expand Down Expand Up @@ -31,6 +32,9 @@ export default async function RootLayout({
children: React.ReactNode;
params: { locale: string };
}) {
// https://next-intl-docs.vercel.app/docs/getting-started/app-router#static-rendering
unstable_setRequestLocale(params.locale);

return (
<html lang={params.locale}>
<body className="text-neutral-800 font-normal bg-white min-w-fit flex">
Expand Down
40 changes: 22 additions & 18 deletions components/editor/common/SunEditorWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use client';

import { MutableRefObject, Suspense, lazy } from 'react';
import { MutableRefObject, lazy } from 'react';
import { ko } from 'suneditor/src/lang/';
import SunEditorCore from 'suneditor/src/lib/core';
import plugins from 'suneditor/src/plugins';

// TODO
// 정말 왜그러는지 모르겠는데 lazy + typeof window 조합으로만 빌드가 됨
// 건들지 말..것..
const SunEditor = lazy(() => import('suneditor-react'));

import './suneditor.css';
Expand All @@ -18,7 +21,7 @@ export default function SunEditorWrapper({
initialContent?: string;
}) {
return (
<Suspense fallback={<SunEditorFallback />}>
typeof window !== 'undefined' && (
<SunEditor
getSunEditorInstance={(x) => (editorRef.current = x)}
setDefaultStyle={`padding: 1rem;`}
Expand All @@ -39,25 +42,26 @@ export default function SunEditorWrapper({
// imageUploadUrl: `${BASE_URL}/file/upload`,
}}
/>
</Suspense>
)
);
}

const SunEditorFallback = () => {
return (
<div className="animate-pulse flex flex-col mx-[3.75rem] mt-3 h-[400px]">
<div className="flex flex-col gap-2">
<div className="h-4 bg-[#ffffff] opacity-30 rounded w-2/5"></div>
<div className="h-4 bg-[#ffffff] opacity-30 rounded w-2/5"></div>
</div>
<div className="flex flex-1 flex-col gap-2 w-3/5 mt-4">
<div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
<div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
<div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
</div>
</div>
);
};
// Suspense 쓰도록 고칠 때까지 삭제
// const SunEditorFallback = () => {
// return (
// <div className="animate-pulse flex flex-col mx-[3.75rem] mt-3 h-[400px]">
// <div className="flex flex-col gap-2">
// <div className="h-4 bg-[#ffffff] opacity-30 rounded w-2/5"></div>
// <div className="h-4 bg-[#ffffff] opacity-30 rounded w-2/5"></div>
// </div>
// <div className="flex flex-1 flex-col gap-2 w-3/5 mt-4">
// <div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
// <div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
// <div className="h-4 bg-[#ffffff] opacity-30 rounded"></div>
// </div>
// </div>
// );
// };

// https://github.com/JiHong88/SunEditor/issues/199
export const isContentEmpty = (editor: SunEditorCore) => {
Expand Down
9 changes: 8 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: 'standalone',
output: 'standalone',

// TODO: 아래 옵션 없이 빌드
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},

webpack(config) {
// Grab the existing rule that handles SVG imports
Expand Down

0 comments on commit 653ea0d

Please sign in to comment.