Replies: 1 comment
-
我和你一样的问题,怎么解决 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
在开发环境没问题,当打包后,就会报错
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://j1.cdn.com.cn/frs/project/management-web/1.0/ts.worker.js' failed to load.
umi_v1670232861137.js:4628 Uncaught Error: Unexpected usage
Error: Unexpected usage

at Gn.loadForeignModule
下面是我config.js
// https://umijs.org/config/
import { defineConfig } from 'umi';
import { join } from 'path';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { resolve } = require('path');
import routes from './routes';
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
// new MonacoWebpackPlugin()
const { REACT_APP_ENV } = process.env;
export default defineConfig({
favicon: 'https://protocol.corp.com/img/app_coryright_logo.png',
alias: {
'@': resolve(__dirname, '../src'),
components: resolve(__dirname, '../src/components/Editor/app/components'),
assets: resolve(__dirname, '../src/components/Editor/assets'),
app: resolve(__dirname, '../src/components/Editor/app'),
utils: resolve(__dirname, '../src/components/Editor/utils')
},
chainWebpack: (memo) => {
// 更多配置 https://github.com/Microsoft/monaco-editor-webpack-plugin#options
memo.plugin('monaco-editor-webpack-plugin').use(
new MonacoWebpackPlugin({
languages: ['javascript', 'typescript']
})
);
// return memo;
},
publicPath:
process.env.NODE_ENV === 'production'
? 'https://j1.cdn.com.cn/frs/project/management-web/1.0/'
: '/',
// chainWebpack(config, { webpack }) {
// config.plugin('monaco-editor').use(MonacoWebpackPlugin);
// },
// chainWebpack(memo, { env, webpack, createCSSRule }) {
// memo.output.filename('[name].js').chunkFilename('[name].[contenthash:8].async.js');
// memo.plugin('extract-css').tap((args) => [
// {
// filename: '[name].css',
// chunkFilename: '[name].[contenthash:8].chunk.css',
// },
// ]);
// },
nodeModulesTransform: {
type: 'none'
},
plugins: [
// '../node_modules/monaco-editor/min/vs/language/typescript/ts.worker.js'
],
hash: false,
antd: {},
dva: {
hmr: true
},
layout: {
// https://umijs.org/zh-CN/plugins/plugin-layout
locale: false,
siderWidth: 208,
...defaultSettings
},
// https://umijs.org/zh-CN/plugins/plugin-locale
// locale: {
// // default zh-CN
// enable: false,
// // default: 'zh-CN',
// antd: false,
// // default true, when it is true, will use
navigator.language
overwrite default// baseNavigator: false
// },
// dynamicImport: {
// loading: '@ant-design/pro-layout/es/PageLoading',
// },
targets: {
ie: 11
},
// umi routes: https://umijs.org/docs/routing
routes,
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
'primary-color': defaultSettings.primaryColor
},
// esbuild is father build tools
// https://umijs.org/plugins/plugin-esbuild
esbuild: {},
title: false,
ignoreMomentLocale: true,
proxy: proxy[REACT_APP_ENV || 'dev'],
// manifest: {
// basePath: '/',
// },
// Fast Refresh 热更新
fastRefresh: {},
openAPI: [
{
requestLibPath: "import { request } from 'umi'",
// 或者使用在线的版本
// schemaPath: "https://gw.alipayobjects.com/os/antfincdn/M%24jrzTTYJN/oneapi.json"
schemaPath: join(__dirname, 'oneapi.json'),
mock: false
},
{
requestLibPath: "import { request } from 'umi'",
schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json',
projectName: 'swagger'
}
],
// publicPath: '/src/',
// chainWebpack(memo, { env, webpack, createCSSRule }) {
// memo.plugin('111').use(
// new webpack.ProvidePlugin({
// 'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
// 'ts.worker': 'monaco-editor/esm/vs/language/typescript/ts.worker'
// })
// );
// },
// entry: {
// 'editor.worker': 'monaco-editor/esm/vs/editor/editor.worker.js',
// 'json.worker': 'monaco-editor/esm/vs/language/json/json.worker',
// 'css.worker': 'monaco-editor/esm/vs/language/css/css.worker',
// 'html.worker': 'monaco-editor/esm/vs/language/html/html.worker',
// 'ts.worker': 'monaco-editor/esm/vs/language/typescript/ts.worker'
// },
nodeModulesTransform: {
type: 'none'
},
// mfsu: {},
webpack5: {}
// chainWebpack(config) {
// config.module
// .rule('svg')
// .test(/.(woff|eot|woff2|ttf|svg)$/)
// .use('file-loader')
// .loader('file-loader');
// },
// entry: ['111'],
// exportStatic: {},
});
Beta Was this translation helpful? Give feedback.
All reactions