build: 使用esbuildOptions定义global

This commit is contained in:
roymondchen 2022-09-06 15:31:17 +08:00 committed by jia000
parent 08faee9cab
commit 458f493150
6 changed files with 17 additions and 34 deletions

View File

@ -15,8 +15,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import './utils/polyfills';
import { App } from 'vue';
import Code from './fields/Code.vue';

View File

@ -1,8 +0,0 @@
// serialize-javascript 依赖的 randombytes 依赖全局的 global 对象,因此此处需添加 global polyfill
if (typeof global === 'undefined') {
(window as any).global = window;
}
if (typeof globalThis === 'undefined') {
(window as any).globalThis = window;
}

View File

@ -39,6 +39,14 @@ export default defineConfig({
],
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
build: {
cssCodeSplit: false,
sourcemap: true,

View File

@ -16,8 +16,6 @@
* limitations under the License.
*/
import './polyfills';
import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';

View File

@ -1,21 +0,0 @@
/*
* Tencent is pleased to support the open source community by making TMagicEditor available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (typeof (window as any).global === 'undefined') {
(window as any).global = window;
}

View File

@ -33,7 +33,7 @@ export default defineConfig({
}),
],
base: '/tmagic-editor/playground',
base: '/tmagic-editor/playground/',
resolve: {
alias: [
@ -53,6 +53,14 @@ export default defineConfig({
],
},
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis',
},
},
},
server: {
fs: {
strict: false,