-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import * as path from 'node:path' | ||
import fs from 'node:fs' | ||
import { cwd } from 'node:process' | ||
import { build } from 'vite' | ||
|
||
import react from '@vitejs/plugin-react' | ||
import dts from 'vite-plugin-dts' | ||
import tailwind from 'tailwindcss' | ||
import autoprefixer from 'autoprefixer' | ||
import postcssReplace from 'postcss-replace' | ||
|
||
const imports = [ | ||
{ | ||
entry: 'src/index.ts', | ||
fileName: 'index', | ||
}, | ||
{ | ||
entry: 'src/bundle-full.ts', | ||
fileName: 'bundle-full', | ||
}, | ||
] | ||
|
||
const __dirname = cwd() | ||
|
||
imports.forEach(async ({ entry, fileName }) => { | ||
const plugins: any = [react(), dts({ | ||
rollupTypes: true, | ||
afterBuild: (emittedFiles) => { | ||
emittedFiles.forEach((content, filePath) => { | ||
if (filePath.endsWith('.d.ts')) { | ||
const newFilePath = filePath.replace('.d.ts', '.d.cts') | ||
|
||
fs.writeFileSync(newFilePath, content) | ||
} | ||
}) | ||
}, | ||
})] | ||
|
||
await build({ | ||
configFile: false, | ||
plugins, | ||
resolve: { | ||
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }], | ||
}, | ||
css: { | ||
postcss: { | ||
plugins: [ | ||
tailwind(), | ||
autoprefixer(), | ||
postcssReplace({ | ||
pattern: /(--tw|\*, ::before, ::after)/g, | ||
data: { | ||
'--tw': '--richtext', // Prefixing | ||
'*, ::before, ::after': ':root', // So variables does not pollute every element | ||
}, | ||
}), | ||
], | ||
}, | ||
preprocessorOptions: { | ||
scss: { | ||
charset: false, | ||
api: 'modern-compiler', // or 'modern' | ||
}, | ||
}, | ||
}, | ||
build: { | ||
cssMinify: 'esbuild', | ||
minify: 'esbuild', | ||
outDir: 'lib', | ||
lib: { | ||
entry: path.resolve(__dirname, entry), | ||
formats: ['es', 'cjs'], | ||
fileName, | ||
}, | ||
rollupOptions: { | ||
input: { | ||
index: path.resolve(__dirname, entry), | ||
}, | ||
output: entry === 'src/index.ts' | ||
? { | ||
manualChunks(id) { | ||
if (id.includes('@tiptap')) { | ||
return 'tiptap' | ||
} | ||
if (id.includes('node_modules')) { | ||
return 'vendor' | ||
} | ||
if (id.includes('src/utils')) { | ||
return 'utils' | ||
} | ||
if (id.includes('src/locales')) { | ||
return 'locales' | ||
} | ||
}, | ||
} | ||
: {}, | ||
external: entry === 'src/index.ts' ? ['react', 'react-dom', 'react/jsx-runtime', 'katex', 'shiki', 'docx', '@radix-ui/react-dropdown-menu', '@radix-ui/react-icons', '@radix-ui/react-label', '@radix-ui/react-popover', '@radix-ui/react-separator', '@radix-ui/react-slot', '@radix-ui/react-switch', '@radix-ui/react-tabs', '@radix-ui/react-toast', '@radix-ui/react-toggle', '@radix-ui/react-tooltip', '@radix-ui/react-select', '@radix-ui/react-checkbox', 'react-colorful', 'scroll-into-view-if-needed', 'tippy.js', 'lucide-react', 'prosemirror-docx', 're-resizable', '@excalidraw/excalidraw', '@radix-ui/react-dialog', 'react-image-crop', 'mermaid', 'react-tweet', 'reactjs-signal'] : ['react', 'react-dom', 'react/jsx-runtime', 'katex', 'shiki', '@radix-ui/react-dropdown-menu', '@radix-ui/react-icons', '@radix-ui/react-label', '@radix-ui/react-popover', '@radix-ui/react-separator', '@radix-ui/react-slot', '@radix-ui/react-switch', '@radix-ui/react-tabs', '@radix-ui/react-toast', '@radix-ui/react-toggle', '@radix-ui/react-tooltip', '@radix-ui/react-select', '@radix-ui/react-checkbox', 'react-colorful', 'scroll-into-view-if-needed', 'tippy.js', 'lucide-react', 're-resizable', '@excalidraw/excalidraw', '@radix-ui/react-dialog', 'react-image-crop', 'mermaid', 'react-tweet', 'reactjs-signal'], | ||
}, | ||
}, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable import/first */ | ||
export * from '@/extensions' | ||
|
||
export { default } from '@/components/RichTextEditor' | ||
|
||
import locale, { en, hu_HU, pt_BR, vi, zh_CN } from './locales' | ||
import { useEditorState } from '@/hooks/useEditorState' | ||
|
||
export { locale, en, hu_HU, vi, zh_CN, pt_BR } | ||
|
||
export type { UseEditorStateReturn } from '@/hooks/useEditorState' | ||
export { useEditorState } | ||
export type { Editor, UseEditorOptions } from '@tiptap/react' | ||
export { BubbleMenu } from '@tiptap/react' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters