mirror of
https://github.com/ershisan99/md-preview-desktop.git
synced 2025-12-16 20:59:24 +00:00
chore: use lib instead of copy-pasting bundling module
This commit is contained in:
@@ -5,26 +5,7 @@ import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
main: {
|
main: {
|
||||||
build: {
|
plugins: [externalizeDepsPlugin({ exclude: ['rehype-slug', '@it-incubator/md-bundler'] })],
|
||||||
rollupOptions: {
|
|
||||||
// external: ['builtin-modules'],
|
|
||||||
// output: {
|
|
||||||
// manualChunks(id) {
|
|
||||||
// if (id.includes('builtin-modules')) {
|
|
||||||
// return 'builtin-modules'
|
|
||||||
// }
|
|
||||||
// if (id.includes('@it-incubator/md-bundler')) {
|
|
||||||
// return '@it-incubator/md-bundler'
|
|
||||||
// }
|
|
||||||
// if (id.includes('esbuild')) {
|
|
||||||
// return 'esbuild'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// plugins: [externalizeDepsPlugin({ exclude: ['@it-incubator/md-bundler', 'builtin-modules'] })],
|
|
||||||
plugins: [externalizeDepsPlugin({ exclude: ['rehype-slug'] })],
|
|
||||||
},
|
},
|
||||||
preload: {
|
preload: {
|
||||||
plugins: [externalizeDepsPlugin()],
|
plugins: [externalizeDepsPlugin()],
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
"@electron-toolkit/preload": "^2.0.0",
|
"@electron-toolkit/preload": "^2.0.0",
|
||||||
"@electron-toolkit/utils": "^2.0.0",
|
"@electron-toolkit/utils": "^2.0.0",
|
||||||
"@fontsource/roboto": "^5.0.8",
|
"@fontsource/roboto": "^5.0.8",
|
||||||
"@it-incubator/mdx-components": "^0.0.2",
|
"@it-incubator/md-bundler": "0.0.8",
|
||||||
"@it-incubator/ui-kit": "^0.2.7",
|
"@it-incubator/mdx-components": "0.0.3",
|
||||||
|
"@it-incubator/ui-kit": "0.2.17",
|
||||||
"builtin-modules": "^3.3.0",
|
"builtin-modules": "^3.3.0",
|
||||||
"chokidar": "^3.5.3",
|
"chokidar": "^3.5.3",
|
||||||
"electron-updater": "^6.1.1",
|
"electron-updater": "^6.1.1",
|
||||||
|
|||||||
2078
pnpm-lock.yaml
generated
2078
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,47 +0,0 @@
|
|||||||
import { bundleMDX } from 'mdx-bundler'
|
|
||||||
import rehypePrettyCode from 'rehype-pretty-code'
|
|
||||||
import rehypeSlug from 'rehype-slug'
|
|
||||||
|
|
||||||
import { CODE_BLOCK_FILENAME_REGEX } from './constants'
|
|
||||||
import { attachMeta, parseMeta } from './rehype'
|
|
||||||
import theme from './theme.json'
|
|
||||||
import { BundledMdx } from './types'
|
|
||||||
|
|
||||||
export const bundleMdx = async (source: string): Promise<BundledMdx> => {
|
|
||||||
return await bundleMDX({
|
|
||||||
globals: {
|
|
||||||
components: '@it-incubator/mdx-components',
|
|
||||||
},
|
|
||||||
mdxOptions(options) {
|
|
||||||
options.rehypePlugins = [
|
|
||||||
...(options.rehypePlugins ?? []),
|
|
||||||
rehypeSlug,
|
|
||||||
[parseMeta, { defaultShowCopyCode: true }],
|
|
||||||
[
|
|
||||||
rehypePrettyCode,
|
|
||||||
{
|
|
||||||
filterMetaString: (meta: string) => meta.replace(CODE_BLOCK_FILENAME_REGEX, ''),
|
|
||||||
onVisitHighlightedChars(node: any) {
|
|
||||||
node.properties.className = ['highlighted']
|
|
||||||
},
|
|
||||||
onVisitHighlightedLine(node: any) {
|
|
||||||
node.properties.className.push('highlighted')
|
|
||||||
},
|
|
||||||
onVisitLine(node: any) {
|
|
||||||
// Prevent lines from collapsing in `display: grid` mode, and
|
|
||||||
// allow empty lines to be copy/pasted
|
|
||||||
if (node.children.length === 0) {
|
|
||||||
node.children = [{ type: 'text', value: ' ' }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
theme,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
attachMeta,
|
|
||||||
]
|
|
||||||
|
|
||||||
return options
|
|
||||||
},
|
|
||||||
source,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -3,10 +3,10 @@ import path from 'node:path'
|
|||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
|
||||||
import { electronApp, is, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, is, optimizer } from '@electron-toolkit/utils'
|
||||||
|
import { bundleMdx } from '@it-incubator/md-bundler'
|
||||||
import { BrowserWindow, app, ipcMain, shell } from 'electron'
|
import { BrowserWindow, app, ipcMain, shell } from 'electron'
|
||||||
|
|
||||||
import icon from '../../resources/icon.png?asset'
|
import icon from '../../resources/icon.png?asset'
|
||||||
import { bundleMdx } from './bundle-mdx'
|
|
||||||
const chokidar = require('chokidar')
|
const chokidar = require('chokidar')
|
||||||
|
|
||||||
let mainWindow: BrowserWindow | null = null
|
let mainWindow: BrowserWindow | null = null
|
||||||
|
|||||||
@@ -180,10 +180,6 @@
|
|||||||
padding-inline: 1rem;
|
padding-inline: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not([data-theme]) {
|
|
||||||
@apply px-4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
& img {
|
& img {
|
||||||
|
|||||||
Reference in New Issue
Block a user