-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsx-explorer): support browser env
- Loading branch information
Showing
6 changed files
with
137 additions
and
679 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'; | ||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'; | ||
|
||
// @ts-ignore | ||
self.MonacoEnvironment = { | ||
globalAPI: true, | ||
getWorker(_: any, label: string) { | ||
if (label === 'typescript' || label === 'javascript') { | ||
return new tsWorker(); | ||
} | ||
return new editorWorker(); | ||
}, | ||
}; |
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 @@ | ||
/// <reference types="vite/client" /> |
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 |
---|---|---|
@@ -1,22 +1,27 @@ | ||
import { defineConfig } from 'vite'; | ||
import { nodePolyfills } from 'vite-plugin-node-polyfills'; | ||
import VueJSX from '@vitejs/plugin-vue-jsx'; | ||
import MonacoEditorPlugin from 'vite-plugin-monaco-editor'; | ||
import Replace from 'unplugin-replace/vite'; | ||
|
||
export default defineConfig({ | ||
build: { | ||
minify: 'terser', | ||
}, | ||
resolve: { | ||
alias: { | ||
'@vue/babel-plugin-jsx': '@vue/babel-plugin-jsx/src/index.ts', | ||
path: 'pathe', | ||
}, | ||
}, | ||
plugins: [ | ||
VueJSX(), | ||
// @ts-expect-error | ||
(MonacoEditorPlugin.default as typeof MonacoEditorPlugin)({ | ||
languageWorkers: ['editorWorkerService', 'typescript'], | ||
}), | ||
nodePolyfills({ | ||
globals: { process: true }, | ||
Replace({ | ||
values: { | ||
'process.env.BABEL_TYPES_8_BREAKING': 'false', | ||
'process.env.BABEL_ENV': '"development"', | ||
'process.env.NODE_NDEBUG': 'true', | ||
'process.env.NODE_DEBUG': 'false', | ||
'Buffer.isBuffer': 'function isBuffer() { return false; }', | ||
}, | ||
}), | ||
], | ||
}); |
Oops, something went wrong.