chore: 调整 vite 后 gh-pages 问题修复 (#5682)

* chore: 调整 vite 后 gh-pages 问题修复

* 降级monaco-editor
This commit is contained in:
liaoxuezhi 2022-11-03 12:12:14 +08:00 committed by GitHub
parent c591ab4381
commit cd7d6062aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -137,7 +137,7 @@ fis.match('monaco-editor/min/**.js', {
ignoreDependencies: true ignoreDependencies: true
}); });
fis.match('/docs/**.md', { fis.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
rExt: 'js', rExt: 'js',
ignoreDependencies: true, ignoreDependencies: true,
parser: [ parser: [
@ -223,7 +223,7 @@ fis.match('*.html:jsx', {
// 这些用了 esm // 这些用了 esm
fis.match( fis.match(
'{echarts/extension/**.js,zrender/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js}', '{echarts/extension/**.js,zrender/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js,axios/**.js}',
{ {
parser: fis.plugin('typescript', { parser: fis.plugin('typescript', {
sourceMap: false, sourceMap: false,
@ -640,7 +640,7 @@ if (fis.project.currentMedia() === 'publish-sdk') {
rExt: '.css' rExt: '.css'
}); });
ghPages.match('/docs/**.md', { ghPages.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
rExt: 'js', rExt: 'js',
isMod: true, isMod: true,
useHash: true, useHash: true,

View File

@ -50,12 +50,13 @@
} }
link.setAttribute( link.setAttribute(
'href', 'href',
new URL(`./packages/amis/lib/themes/${key}.css`, import.meta.url).href new URL(`./packages/amis-ui/scss/themes/${key}.scss`, import.meta.url)
.href
); );
document.head.appendChild(link); document.head.appendChild(link);
}); });
</script> </script>
<link rel="stylesheet" href="./packages/amis/lib/helper.css" /> <link rel="stylesheet" href="./packages/amis-ui/scss/helper.scss" />
</head> </head>
<body> <body>

View File

@ -28,6 +28,7 @@
"qs": "6.9.7" "qs": "6.9.7"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-replace": "^5.0.1",
"@types/express": "^4.17.14", "@types/express": "^4.17.14",
"@types/jest": "^28.1.0", "@types/jest": "^28.1.0",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
@ -67,7 +68,10 @@
"vite": "^3.2.2", "vite": "^3.2.2",
"vite-plugin-monaco-editor": "^1.1.0", "vite-plugin-monaco-editor": "^1.1.0",
"vite-plugin-svgr": "^2.2.2", "vite-plugin-svgr": "^2.2.2",
"zrender": "^5.3.2" "zrender": "^5.3.2",
"monaco-editor": "0.30.1",
"react-overlays": "5.1.1",
"copy-to-clipboard": "3.3.1"
}, },
"jest": { "jest": {
"verbose": true, "verbose": true,

View File

@ -22,13 +22,21 @@ const settings = {
globals: {} globals: {}
}; };
const external = id => const external = id => {
new RegExp( const result = new RegExp(
`^(?:${Object.keys(dependencies) `^(?:${Object.keys(dependencies)
.concat([ .concat([
'react',
'react-dom',
'react-overlays',
'warning',
'tslib',
'dom-helpers',
'@restart/hooks',
'entities', 'entities',
'linkify-it', 'linkify-it',
'markdown-it', 'markdown-it',
'prop-types',
'markdown-it-html5-media', 'markdown-it-html5-media',
'mdurl', 'mdurl',
'uc.micro' 'uc.micro'
@ -38,6 +46,13 @@ const external = id =>
) )
.join('|')})` .join('|')})`
).test(id); ).test(id);
if (!result && ~id.indexOf('node_modules')) {
console.log(id);
}
return result;
};
const input = './src/index.tsx'; const input = './src/index.tsx';
/** 获取子包编译后的入口路径,需要使用相对路径 */ /** 获取子包编译后的入口路径,需要使用相对路径 */

View File

@ -63,7 +63,6 @@
"mobx-react": "^6.3.1", "mobx-react": "^6.3.1",
"mobx-state-tree": "^3.17.3", "mobx-state-tree": "^3.17.3",
"moment": "^2.19.4", "moment": "^2.19.4",
"monaco-editor": "0.30.1",
"mpegts.js": "^1.6.10", "mpegts.js": "^1.6.10",
"prop-types": "^15.6.1", "prop-types": "^15.6.1",
"qrcode.react": "^3.1.0", "qrcode.react": "^3.1.0",

View File

@ -20,15 +20,28 @@ const settings = {
globals: {} globals: {}
}; };
const external = id => const external = id => {
new RegExp( const result = new RegExp(
`^(?:${Object.keys(dependencies) `^(?:${Object.keys(dependencies)
.concat([]) .concat([
'monaco-editor',
'react',
'react-dom',
'rc-input-number',
'@babel/runtime'
])
.map(value => .map(value =>
value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d') value.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
) )
.join('|')})` .join('|')})`
).test(id); ).test(id);
if (!result && ~id.indexOf('node_modules')) {
console.log(id);
}
return result;
};
const input = './src/index.tsx'; const input = './src/index.tsx';
/** 获取子包编译后的入口路径,需要使用相对路径 */ /** 获取子包编译后的入口路径,需要使用相对路径 */

View File

@ -4,6 +4,7 @@ import handler from '../mock/index';
import express, {query} from 'express'; import express, {query} from 'express';
import setPrototypeOf from 'setprototypeof'; import setPrototypeOf from 'setprototypeof';
import path from 'path'; import path from 'path';
import fs from 'fs';
const app = express(); const app = express();
function initExpress(req: any, res: any, next: any, callback: () => void) { function initExpress(req: any, res: any, next: any, callback: () => void) {
@ -34,7 +35,22 @@ export default function mockApiPlugin(options: {} = {}): Plugin {
server.middlewares.use('/schema.json', (req, res, next) => { server.middlewares.use('/schema.json', (req, res, next) => {
initExpress(req, res, next, () => { initExpress(req, res, next, () => {
res.sendFile(path.resolve(__dirname, '../packages/amis/schema.json')); const filepath = path.resolve(
__dirname,
'../packages/amis/schema.json'
);
if (!fs.existsSync(filepath)) {
res.json({
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
description:
'amis/schema.json 还没有构建,请执行 `npm run build-schemas --workspace amis` 后看效果'
});
return;
}
res.sendFile(filepath);
}); });
}); });
} }