Skip to content

Commit

Permalink
refactor: external TS of worker (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Jul 5, 2023
1 parent 4301d86 commit f9ed9cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion empty.js

This file was deleted.

15 changes: 4 additions & 11 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'node:path'
import { defineConfig, Plugin, UserConfig } from 'vite'
import { Plugin, mergeConfig } from 'vite'
import base from './vite.preview.config'

const genStub: Plugin = {
Expand All @@ -14,28 +13,22 @@ const genStub: Plugin = {
},
}

export default defineConfig({
...base,
plugins: [...(base as UserConfig).plugins!, genStub],
export default mergeConfig(base, {
plugins: [genStub],
optimizeDeps: {
// avoid late discovered deps
include: [
'path-browserify',
'onigasm',
'typescript',
'@volar/cdn',
'@vue/language-service',
'monaco-editor-core/esm/vs/editor/editor.worker',
'@volar/monaco/worker',
'vue/server-renderer',
],
},
base: './',
resolve: {
alias: {
typescript: path.resolve(__dirname, './empty.js'),
path: 'path-browserify',
},
},
build: {
target: 'esnext',
minify: false,
Expand Down
7 changes: 5 additions & 2 deletions vite.preview.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import replace from '@rollup/plugin-replace'
Expand All @@ -13,10 +12,14 @@ export default defineConfig({
],
resolve: {
alias: {
typescript: path.resolve(__dirname, './empty.js'),
path: 'path-browserify',
},
},
build: {
commonjsOptions: {
ignore: ['typescript'],
},
},
worker: {
format: 'es',
plugins: [
Expand Down

0 comments on commit f9ed9cb

Please sign in to comment.