fix(web-admin): polyfill Buffer/global for contract Word export in Vite
html-to-docx still reads Node globals after Vite rebundles; inject buffer polyfill, map global to globalThis, and alias the package to the browser build. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8bbc716d17
commit
f872333df6
5 files changed
+58
-5
No files matched your search
@@ -22,7 +22,9 @@ export default ({ mode }: { mode: string }) => {
|
||||
|
||||
return defineConfig({
|
||||
define: {
|
||||
__APP_VERSION__: JSON.stringify(VITE_VERSION)
|
||||
__APP_VERSION__: JSON.stringify(VITE_VERSION),
|
||||
// html-to-docx 等依赖会读 Node 全局;浏览器映射到 globalThis
|
||||
global: 'globalThis'
|
||||
},
|
||||
base: VITE_BASE_URL,
|
||||
server: {
|
||||
@@ -56,7 +58,12 @@ export default ({ mode }: { mode: string }) => {
|
||||
'@icons': resolvePath('src/assets/icons'),
|
||||
'@utils': resolvePath('src/utils'),
|
||||
'@stores': resolvePath('src/store'),
|
||||
'@styles': resolvePath('src/assets/styles')
|
||||
'@styles': resolvePath('src/assets/styles'),
|
||||
// 合同 Word 导出:强制 browser 构建,避免 Vite 落到 Node ESM
|
||||
'@turbodocx/html-to-docx': resolvePath(
|
||||
'node_modules/@turbodocx/html-to-docx/dist/html-to-docx.browser.esm.js'
|
||||
),
|
||||
buffer: 'buffer/'
|
||||
}
|
||||
},
|
||||
build: {
|
||||
@@ -140,6 +147,7 @@ export default ({ mode }: { mode: string }) => {
|
||||
'xgplayer',
|
||||
'crypto-js',
|
||||
'file-saver',
|
||||
'buffer',
|
||||
'vue-img-cutter',
|
||||
'element-plus/es',
|
||||
'element-plus/es/components/*/style/css',
|
||||
|
||||
Reference in new issue
Block a user