2019-04-30 11:11:25 +08:00
|
|
|
|
/**
|
|
|
|
|
* @file fis-conf.js 配置
|
|
|
|
|
*/
|
2019-05-09 18:25:12 +08:00
|
|
|
|
const path = require('path');
|
2020-04-02 17:48:26 +08:00
|
|
|
|
const fs = require('fs');
|
2022-06-01 15:06:00 +08:00
|
|
|
|
const package = require('./packages/amis/package.json');
|
2020-09-08 17:39:14 +08:00
|
|
|
|
const parserMarkdown = require('./scripts/md-parser');
|
2020-12-29 13:06:53 +08:00
|
|
|
|
const convertSCSSIE11 = require('./scripts/scss-ie11');
|
2020-11-30 00:37:09 +08:00
|
|
|
|
const parserCodeMarkdown = require('./scripts/code-md-parser');
|
2022-06-02 13:28:23 +08:00
|
|
|
|
fis.set('project.ignore', [
|
|
|
|
|
'public/**',
|
|
|
|
|
'scripts/**',
|
|
|
|
|
'npm/**',
|
|
|
|
|
'gh-pages/**',
|
2022-09-15 19:16:44 +08:00
|
|
|
|
'.*/**',
|
|
|
|
|
'node_modules/**'
|
2022-06-02 13:28:23 +08:00
|
|
|
|
]);
|
2019-04-30 11:11:25 +08:00
|
|
|
|
// 配置只编译哪些文件。
|
2022-07-29 16:36:15 +08:00
|
|
|
|
|
2020-07-20 18:03:10 +08:00
|
|
|
|
const Resource = fis.require('postpackager-loader/lib/resource.js');
|
2021-06-24 20:59:28 +08:00
|
|
|
|
const versionHash = fis.util.md5(package.version);
|
2020-07-20 18:03:10 +08:00
|
|
|
|
|
|
|
|
|
Resource.extend({
|
|
|
|
|
buildResourceMap: function () {
|
2021-06-24 20:59:28 +08:00
|
|
|
|
const resourceMap = this.__super();
|
2021-10-13 13:15:56 +08:00
|
|
|
|
if (resourceMap === '') {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2021-06-24 20:59:28 +08:00
|
|
|
|
|
|
|
|
|
const map = JSON.parse(resourceMap.substring(20, resourceMap.length - 2));
|
|
|
|
|
|
|
|
|
|
Object.keys(map.res).forEach(function (key) {
|
|
|
|
|
if (map.res[key].pkg) {
|
|
|
|
|
map.res[key].pkg = `${versionHash}-${map.res[key].pkg}`;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.keys(map.pkg).forEach(function (key) {
|
|
|
|
|
map.pkg[`${versionHash}-${key}`] = map.pkg[key];
|
|
|
|
|
delete map.pkg[key];
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return `amis.require.resourceMap(${JSON.stringify(map)});`;
|
2020-07-20 18:03:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
calculate: function () {
|
|
|
|
|
this.__super.apply(this);
|
|
|
|
|
|
|
|
|
|
// 标记这个文件,肯定是异步资源,即便是同步加载了。
|
|
|
|
|
Object.keys(this.loaded).forEach(id => {
|
|
|
|
|
const file = this.getFileById(id);
|
|
|
|
|
|
|
|
|
|
if (file && file.subpath === '/examples/loadMonacoEditor.ts') {
|
|
|
|
|
this.loaded[id] = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.set('project.files', [
|
2020-09-16 23:41:51 +08:00
|
|
|
|
'schema.json',
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'/examples/map.json',
|
2020-12-21 10:08:40 +08:00
|
|
|
|
'/scss/helper.scss',
|
2020-11-30 00:37:09 +08:00
|
|
|
|
'/scss/themes/*.scss',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'/examples/*.html',
|
2021-12-22 12:37:45 +08:00
|
|
|
|
'/examples/app/*.html',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'/examples/*.tpl',
|
2021-03-22 21:19:03 +08:00
|
|
|
|
'/examples/static/*.png',
|
|
|
|
|
'/examples/static/*.svg',
|
|
|
|
|
'/examples/static/*.jpg',
|
|
|
|
|
'/examples/static/*.jpeg',
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'/examples/static/*.docx',
|
2021-08-09 18:05:01 +08:00
|
|
|
|
'/examples/static/photo/*.jpeg',
|
|
|
|
|
'/examples/static/photo/*.png',
|
|
|
|
|
'/examples/static/audio/*.mp3',
|
|
|
|
|
'/examples/static/video/*.mp4',
|
2020-09-16 23:41:51 +08:00
|
|
|
|
'mock/**'
|
2019-04-30 11:11:25 +08:00
|
|
|
|
]);
|
|
|
|
|
|
2020-09-16 23:41:51 +08:00
|
|
|
|
fis.match('/schema.json', {
|
|
|
|
|
release: '/$0'
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.match('/mock/**', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
useCompile: false
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2019-08-05 11:11:08 +08:00
|
|
|
|
fis.match('mod.js', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
useCompile: false
|
2019-08-05 11:11:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.match('*.scss', {
|
2020-11-03 11:34:23 +08:00
|
|
|
|
parser: fis.plugin('sass', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
sourceMap: true
|
|
|
|
|
}),
|
|
|
|
|
rExt: '.css'
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-06-08 12:39:35 +08:00
|
|
|
|
fis.match('icons/**.svg', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
rExt: '.js',
|
|
|
|
|
isJsXLike: true,
|
|
|
|
|
isJsLike: true,
|
|
|
|
|
isMod: true,
|
|
|
|
|
parser: [
|
|
|
|
|
fis.plugin('svgr', {
|
|
|
|
|
svgProps: {
|
|
|
|
|
className: 'icon'
|
|
|
|
|
},
|
|
|
|
|
prettier: false,
|
|
|
|
|
dimensions: false
|
|
|
|
|
}),
|
|
|
|
|
fis.plugin('typescript', {
|
|
|
|
|
importHelpers: true,
|
|
|
|
|
esModuleInterop: true,
|
|
|
|
|
experimentalDecorators: true,
|
|
|
|
|
sourceMap: false
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
});
|
2019-09-02 18:22:30 +08:00
|
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.match('/node_modules/**.js', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
isMod: true
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2020-04-15 19:52:31 +08:00
|
|
|
|
fis.match('tinymce/{tinymce.js,plugins/**.js,themes/silver/theme.js}', {
|
|
|
|
|
ignoreDependencies: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fis.match('tinymce/plugins/*/index.js', {
|
|
|
|
|
ignoreDependencies: false
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-06 23:21:30 +08:00
|
|
|
|
fis.match(/(?:mpegts\.js|object\-inspect\/util\.inspect\.js)/, {
|
2020-07-20 18:03:10 +08:00
|
|
|
|
ignoreDependencies: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fis.match('monaco-editor/min/**.js', {
|
|
|
|
|
isMod: false,
|
|
|
|
|
ignoreDependencies: true
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-03 12:12:14 +08:00
|
|
|
|
fis.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
rExt: 'js',
|
2021-10-13 14:11:24 +08:00
|
|
|
|
ignoreDependencies: true,
|
2020-01-20 18:50:01 +08:00
|
|
|
|
parser: [
|
|
|
|
|
parserMarkdown,
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (contents, file) {
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return contents.replace(
|
|
|
|
|
/\bhref=\\('|")(.+?)\\\1/g,
|
|
|
|
|
function (_, quota, link) {
|
|
|
|
|
if (/\.md($|#)/.test(link) && !/^https?\:/.test(link)) {
|
|
|
|
|
let parts = link.split('#');
|
|
|
|
|
parts[0] = parts[0].replace('.md', '');
|
|
|
|
|
return 'href=\\' + quota + parts.join('#') + '\\' + quota;
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return _;
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
2020-12-29 14:51:47 +08:00
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
isMod: true
|
|
|
|
|
});
|
2019-05-09 18:25:12 +08:00
|
|
|
|
|
2020-07-20 18:03:10 +08:00
|
|
|
|
fis.on('compile:optimizer', function (file) {
|
|
|
|
|
if (file.isJsLike && file.isMod) {
|
|
|
|
|
var contents = file.getContent();
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
typeof contents === 'string' &&
|
|
|
|
|
contents.substring(0, 7) === 'define('
|
|
|
|
|
) {
|
|
|
|
|
contents = 'amis.' + contents;
|
|
|
|
|
|
|
|
|
|
contents = contents.replace(
|
|
|
|
|
'function(require, exports, module)',
|
|
|
|
|
'function(require, exports, module, define)'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
file.setContent(contents);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-21 20:03:24 +08:00
|
|
|
|
});
|
|
|
|
|
|
2022-02-09 11:18:32 +08:00
|
|
|
|
fis.match('{*.ts,*.jsx,*.tsx,/examples/**.js,/src/**.js,/src/**.ts}', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
parser: [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
// docsGennerator,
|
2020-01-20 18:50:01 +08:00
|
|
|
|
fis.plugin('typescript', {
|
|
|
|
|
importHelpers: true,
|
|
|
|
|
esModuleInterop: true,
|
|
|
|
|
experimentalDecorators: true,
|
2021-03-10 11:15:11 +08:00
|
|
|
|
inlineSourceMap: true,
|
2021-01-22 15:49:10 +08:00
|
|
|
|
target: 4
|
2019-04-30 11:11:25 +08:00
|
|
|
|
}),
|
|
|
|
|
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (content) {
|
2021-09-01 11:19:49 +08:00
|
|
|
|
return (
|
|
|
|
|
content
|
|
|
|
|
// ts 4.4 生成的代码是 (0, tslib_1.__importStar),直接改成 tslib_1.__importStar
|
|
|
|
|
.replace(/\(\d+, (tslib_\d+\.__importStar)\)/g, '$1')
|
|
|
|
|
.replace(/\b[a-zA-Z_0-9$]+\.__uri\s*\(/g, '__uri(')
|
|
|
|
|
.replace(
|
|
|
|
|
/(return|=>)\s*(tslib_\d+)\.__importStar\(require\(('|")(.*?)\3\)\)/g,
|
|
|
|
|
function (_, r, tslib, quto, value) {
|
|
|
|
|
return `${r} new Promise(function(resolve){require(['${value}'], function(ret) {resolve(${tslib}.__importStar(ret));})})`;
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
preprocessor: fis.plugin('js-require-css'),
|
|
|
|
|
isMod: true,
|
|
|
|
|
rExt: '.js'
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2021-04-19 11:36:28 +08:00
|
|
|
|
fis.match('markdown-it/**', {
|
|
|
|
|
preprocessor: fis.plugin('js-require-file')
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.match('*.html:jsx', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
parser: fis.plugin('typescript'),
|
|
|
|
|
rExt: '.js',
|
|
|
|
|
isMod: false
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2021-04-19 11:30:35 +08:00
|
|
|
|
// 这些用了 esm
|
|
|
|
|
fis.match(
|
2022-11-03 12:12:14 +08:00
|
|
|
|
'{echarts/extension/**.js,zrender/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js,axios/**.js}',
|
2021-04-19 11:30:35 +08:00
|
|
|
|
{
|
|
|
|
|
parser: fis.plugin('typescript', {
|
|
|
|
|
sourceMap: false,
|
|
|
|
|
importHelpers: true,
|
|
|
|
|
esModuleInterop: true,
|
|
|
|
|
emitDecoratorMetadata: false,
|
|
|
|
|
experimentalDecorators: false
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2022-06-08 12:39:35 +08:00
|
|
|
|
if (fis.project.currentMedia() === 'dev') {
|
|
|
|
|
fis.match('/packages/**/*.{ts,tsx,js}', {
|
|
|
|
|
isMod: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 将子工程的查找,跳转到 src 目录去
|
|
|
|
|
// 可能 windows 下跑不了
|
|
|
|
|
const projects = [];
|
|
|
|
|
fs.readdirSync(path.join(__dirname, 'packages')).forEach(file => {
|
|
|
|
|
if (fs.lstatSync(path.join(__dirname, 'packages', file)).isDirectory()) {
|
|
|
|
|
projects.push(file);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
projects.sort(function (a, b) {
|
|
|
|
|
return a.length < b.length ? 1 : a.length === b.length ? 0 : -1;
|
|
|
|
|
});
|
|
|
|
|
projects.length &&
|
|
|
|
|
fis.on('lookup:file', function (info, file) {
|
|
|
|
|
const uri = info.rest;
|
|
|
|
|
let newName = '';
|
|
|
|
|
let pkg = '';
|
|
|
|
|
|
|
|
|
|
if (/^amis\/lib\/themes\/(.*)\.css$/.test(uri)) {
|
2022-06-08 12:55:49 +08:00
|
|
|
|
newName = `/packages/amis-ui/scss/themes/${RegExp.$1}.scss`;
|
2022-06-08 12:39:35 +08:00
|
|
|
|
} else if (/^amis\/lib\/(.*)\.css$/.test(uri)) {
|
2022-06-08 12:55:49 +08:00
|
|
|
|
newName = `/packages/amis-ui/scss/${RegExp.$1}.scss`;
|
2022-06-08 12:39:35 +08:00
|
|
|
|
} else if (
|
|
|
|
|
uri === 'amis-formula/lib/doc' ||
|
|
|
|
|
uri === 'amis-formula/lib/doc.md'
|
|
|
|
|
) {
|
|
|
|
|
// 啥也不干
|
|
|
|
|
} else if ((pkg = projects.find(pkg => uri.indexOf(pkg) === 0))) {
|
|
|
|
|
const parts = uri.split('/');
|
|
|
|
|
if (parts[1] === 'lib') {
|
|
|
|
|
parts.splice(1, 1, 'src');
|
|
|
|
|
} else if (parts.length === 1) {
|
|
|
|
|
parts.push('src', 'index');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newName = `/packages/${parts.join('/')}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newName) {
|
|
|
|
|
delete info.file;
|
|
|
|
|
var result = fis.project.lookup(newName, file);
|
|
|
|
|
if (result.file) {
|
|
|
|
|
info.file = result.file;
|
|
|
|
|
info.id = result.file.getId();
|
|
|
|
|
} else {
|
|
|
|
|
console.log(`\`${newName}\` 找不到`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-01 12:13:07 +08:00
|
|
|
|
fis.on('compile:end', function (file) {
|
|
|
|
|
if (file.subpath === '/packages/amis-core/src/index.tsx') {
|
|
|
|
|
file.setContent(
|
|
|
|
|
file
|
|
|
|
|
.getContent()
|
|
|
|
|
.replace(/__buildVersion/g, JSON.stringify(package.version))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-06-08 12:39:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-01 17:54:08 +08:00
|
|
|
|
fis.unhook('components');
|
2019-04-30 11:11:25 +08:00
|
|
|
|
fis.hook('node_modules', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
shimProcess: false,
|
|
|
|
|
shimGlobal: false,
|
2020-04-16 10:56:33 +08:00
|
|
|
|
shimBuffer: false
|
|
|
|
|
// shutup: true
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
fis.hook('commonjs', {
|
2020-07-20 18:03:10 +08:00
|
|
|
|
sourceMap: false,
|
|
|
|
|
extList: ['.js', '.jsx', '.tsx', '.ts'],
|
|
|
|
|
paths: {
|
|
|
|
|
'monaco-editor': '/examples/loadMonacoEditor'
|
|
|
|
|
}
|
2019-04-30 11:11:25 +08:00
|
|
|
|
});
|
|
|
|
|
|
2020-12-25 12:35:54 +08:00
|
|
|
|
fis.match('_*.scss', {
|
|
|
|
|
release: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fis.media('dev').match('_*.scss', {
|
|
|
|
|
parser: [
|
|
|
|
|
parserCodeMarkdown,
|
|
|
|
|
function (contents, file) {
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return contents.replace(
|
|
|
|
|
/\bhref=\\('|")(.+?)\\\1/g,
|
|
|
|
|
function (_, quota, link) {
|
|
|
|
|
if (/\.md($|#)/.test(link) && !/^https?\:/.test(link)) {
|
|
|
|
|
let parts = link.split('#');
|
|
|
|
|
parts[0] = parts[0].replace('.md', '');
|
|
|
|
|
|
|
|
|
|
if (parts[0][0] !== '/') {
|
|
|
|
|
parts[0] = path
|
|
|
|
|
.resolve(path.dirname(file.subpath), parts[0])
|
|
|
|
|
.replace(/^\/docs/, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'href=\\' + quota + parts.join('#') + '\\' + quota;
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return _;
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
2020-12-29 14:51:47 +08:00
|
|
|
|
);
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
release: '$0',
|
|
|
|
|
isMod: true,
|
|
|
|
|
rExt: '.js'
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-21 11:50:23 +08:00
|
|
|
|
fis.media('dev').match('::package', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
postpackager: fis.plugin('loader', {
|
|
|
|
|
useInlineMap: false,
|
|
|
|
|
resourceType: 'mod'
|
|
|
|
|
})
|
|
|
|
|
});
|
2019-08-06 15:45:46 +08:00
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
fis.media('dev').match('/node_modules/**.js', {
|
|
|
|
|
packTo: '/pkg/npm.js'
|
|
|
|
|
});
|
2019-04-30 11:11:25 +08:00
|
|
|
|
|
2022-06-01 15:06:00 +08:00
|
|
|
|
fis.match('{monaco-editor,amis,amis-core}/**', {
|
2020-07-20 18:03:10 +08:00
|
|
|
|
packTo: null
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-01 15:06:00 +08:00
|
|
|
|
if (fis.project.currentMedia() === 'publish-sdk') {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
const env = fis.media('publish-sdk');
|
|
|
|
|
|
2021-01-19 14:30:01 +08:00
|
|
|
|
fis.on('compile:end', function (file) {
|
|
|
|
|
if (
|
2022-06-07 12:45:10 +08:00
|
|
|
|
file.subpath === '/packages/amis/src/index.tsx' ||
|
2021-06-24 20:59:28 +08:00
|
|
|
|
file.subpath === '/examples/mod.js' ||
|
|
|
|
|
file.subpath === '/examples/loader.ts'
|
2021-01-19 14:30:01 +08:00
|
|
|
|
) {
|
2021-06-24 20:59:28 +08:00
|
|
|
|
file.setContent(file.getContent().replace(/@version/g, package.version));
|
2022-10-31 20:53:36 +08:00
|
|
|
|
} else if (file.subpath === '/packages/amis-core/src/index.tsx') {
|
|
|
|
|
file.setContent(
|
|
|
|
|
file
|
|
|
|
|
.getContent()
|
|
|
|
|
.replace(/__buildVersion/g, JSON.stringify(package.version))
|
|
|
|
|
);
|
2021-01-19 14:30:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
env.get('project.ignore').push('sdk/**');
|
|
|
|
|
env.set('project.files', ['examples/sdk-placeholder.html']);
|
|
|
|
|
|
2020-09-27 12:28:40 +08:00
|
|
|
|
env.match('/{examples,scss,src}/(**)', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
release: '/$1'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('*.map', {
|
|
|
|
|
release: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('/node_modules/(**)', {
|
|
|
|
|
release: '/thirds/$1'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('/node_modules/(*)/dist/(**)', {
|
|
|
|
|
release: '/thirds/$1/$2'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('*.scss', {
|
2020-11-03 11:40:24 +08:00
|
|
|
|
parser: fis.plugin('sass', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
sourceMap: false
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
2022-02-09 11:18:32 +08:00
|
|
|
|
env.match('{*.ts,*.jsx,*.tsx,/examples/**.js,/src/**.js,/src/**.ts}', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
parser: [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
// docsGennerator,
|
2020-01-20 18:50:01 +08:00
|
|
|
|
fis.plugin('typescript', {
|
|
|
|
|
importHelpers: true,
|
|
|
|
|
esModuleInterop: true,
|
|
|
|
|
experimentalDecorators: true,
|
|
|
|
|
sourceMap: false
|
|
|
|
|
}),
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (content) {
|
2020-12-03 13:07:58 +08:00
|
|
|
|
return content
|
|
|
|
|
.replace(/\b[a-zA-Z_0-9$]+\.__uri\s*\(/g, '__uri(')
|
2021-09-01 11:19:49 +08:00
|
|
|
|
.replace(/\(\d+, (tslib_\d+\.__importStar)\)/g, '$1')
|
2020-12-03 13:07:58 +08:00
|
|
|
|
.replace(
|
|
|
|
|
/return\s+(tslib_\d+)\.__importStar\(require\(('|")(.*?)\2\)\);/g,
|
|
|
|
|
function (_, tslib, quto, value) {
|
|
|
|
|
return `return new Promise(function(resolve){require(['${value}'], function(ret) {resolve(${tslib}.__importStar(ret));})});`;
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
preprocessor: fis.plugin('js-require-css'),
|
|
|
|
|
isMod: true,
|
|
|
|
|
rExt: '.js'
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-27 12:28:40 +08:00
|
|
|
|
env.match('/examples/mod.js', {
|
|
|
|
|
isMod: false,
|
2021-04-06 10:50:17 +08:00
|
|
|
|
optimizer: fis.plugin('terser')
|
2020-01-20 18:50:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('*.{js,jsx,ts,tsx}', {
|
2021-04-06 10:50:17 +08:00
|
|
|
|
optimizer: fis.plugin('terser'),
|
2020-06-08 19:10:38 +08:00
|
|
|
|
moduleId: function (m, path) {
|
2021-06-24 20:59:28 +08:00
|
|
|
|
return fis.util.md5(package.version + 'amis-sdk' + path);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('::package', {
|
|
|
|
|
packager: fis.plugin('deps-pack', {
|
|
|
|
|
'sdk.js': [
|
2020-07-20 18:03:10 +08:00
|
|
|
|
'examples/mod.js',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'examples/embed.tsx',
|
|
|
|
|
'examples/embed.tsx:deps',
|
2020-07-20 18:03:10 +08:00
|
|
|
|
'examples/loadMonacoEditor.ts',
|
2021-08-06 16:10:12 +08:00
|
|
|
|
'!mpegts.js/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!hls.js/**',
|
|
|
|
|
'!froala-editor/**',
|
2021-12-20 18:54:13 +08:00
|
|
|
|
'!codemirror/**',
|
2020-04-15 16:27:38 +08:00
|
|
|
|
'!tinymce/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!zrender/**',
|
|
|
|
|
'!echarts/**',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'!echarts-stat/**',
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'!papaparse/**',
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'!exceljs/**',
|
2020-07-20 18:03:10 +08:00
|
|
|
|
'!docsearch.js/**',
|
2020-09-27 12:28:40 +08:00
|
|
|
|
'!monaco-editor/**.css',
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'!amis-ui/lib/components/RichText.js',
|
|
|
|
|
'!amis-ui/lib/components/Tinymce.js',
|
|
|
|
|
'!amis-ui/lib/components/ColorPicker.js',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'!react-color/**',
|
|
|
|
|
'!material-colors/**',
|
|
|
|
|
'!reactcss/**',
|
|
|
|
|
'!tinycolor2/**',
|
|
|
|
|
'!cropperjs/**',
|
|
|
|
|
'!react-cropper/**',
|
2022-01-28 16:01:02 +08:00
|
|
|
|
'!jsbarcode/**',
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'!amis-ui/lib/components/BarCode.js',
|
|
|
|
|
'!amis-ui/lib/renderers/Form/CityDB.js',
|
|
|
|
|
'!amis-ui/lib/components/Markdown.js',
|
|
|
|
|
'!amis-core/lib/utils/markdown.js',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'!highlight.js/**',
|
|
|
|
|
'!entities/**',
|
|
|
|
|
'!linkify-it/**',
|
|
|
|
|
'!mdurl/**',
|
|
|
|
|
'!uc.micro/**',
|
2021-04-21 21:31:43 +08:00
|
|
|
|
'!markdown-it/**',
|
2021-09-15 23:22:57 +08:00
|
|
|
|
'!markdown-it-html5-media/**',
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'!punycode/**',
|
|
|
|
|
'!office-viewer/**',
|
|
|
|
|
'!fflate/**'
|
2020-01-20 18:50:01 +08:00
|
|
|
|
],
|
|
|
|
|
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'rich-text.js': [
|
|
|
|
|
'amis-ui/lib/components/RichText.js',
|
|
|
|
|
'froala-editor/**'
|
|
|
|
|
],
|
2020-01-20 18:50:01 +08:00
|
|
|
|
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'tinymce.js': ['amis-ui/lib/components/Tinymce.js', 'tinymce/**'],
|
2020-04-15 16:04:08 +08:00
|
|
|
|
|
2021-12-20 18:54:13 +08:00
|
|
|
|
'codemirror.js': ['codemirror/**'],
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'papaparse.js': ['papaparse/**'],
|
|
|
|
|
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'exceljs.js': ['exceljs/**'],
|
|
|
|
|
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'markdown.js': [
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'amis-ui/lib/components/Markdown.js',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'highlight.js/**',
|
|
|
|
|
'entities/**',
|
|
|
|
|
'linkify-it/**',
|
|
|
|
|
'mdurl/**',
|
|
|
|
|
'uc.micro/**',
|
2021-04-21 21:31:43 +08:00
|
|
|
|
'markdown-it/**',
|
2021-09-15 23:22:57 +08:00
|
|
|
|
'markdown-it-html5-media/**',
|
2021-04-21 21:31:43 +08:00
|
|
|
|
'punycode/**'
|
2021-04-19 11:36:28 +08:00
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'color-picker.js': [
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'amis-ui/lib/components/ColorPicker.js',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'react-color/**',
|
|
|
|
|
'material-colors/**',
|
|
|
|
|
'reactcss/**',
|
|
|
|
|
'tinycolor2/**'
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'cropperjs.js': ['cropperjs/**', 'react-cropper/**'],
|
|
|
|
|
|
2022-01-28 16:01:02 +08:00
|
|
|
|
'barcode.js': ['src/components/BarCode.tsx', 'jsbarcode/**'],
|
|
|
|
|
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'charts.js': ['zrender/**', 'echarts/**', 'echarts-stat/**'],
|
2020-01-20 18:50:01 +08:00
|
|
|
|
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'office-viewer.js': ['office-viewer/**', 'fflate/**'],
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'rest.js': [
|
|
|
|
|
'*.js',
|
|
|
|
|
'!monaco-editor/**',
|
2021-12-20 18:54:13 +08:00
|
|
|
|
'!codemirror/**',
|
2021-08-06 16:10:12 +08:00
|
|
|
|
'!mpegts.js/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!hls.js/**',
|
|
|
|
|
'!froala-editor/**',
|
2021-11-01 15:59:37 +08:00
|
|
|
|
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'!amis-ui/lib/components/RichText.js',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!zrender/**',
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'!echarts/**',
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'!papaparse/**',
|
2021-04-19 11:36:28 +08:00
|
|
|
|
'!exceljs/**',
|
|
|
|
|
'!highlight.js/**',
|
|
|
|
|
'!argparse/**',
|
|
|
|
|
'!entities/**',
|
|
|
|
|
'!linkify-it/**',
|
|
|
|
|
'!mdurl/**',
|
|
|
|
|
'!uc.micro/**',
|
2021-09-15 23:22:57 +08:00
|
|
|
|
'!markdown-it/**',
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'!markdown-it-html5-media/**',
|
|
|
|
|
'!office-viewer/**',
|
|
|
|
|
'!fflate/**'
|
2020-01-20 18:50:01 +08:00
|
|
|
|
]
|
|
|
|
|
}),
|
|
|
|
|
postpackager: [
|
|
|
|
|
fis.plugin('loader', {
|
|
|
|
|
useInlineMap: false,
|
|
|
|
|
resourceType: 'mod'
|
|
|
|
|
}),
|
|
|
|
|
|
2020-09-08 17:39:14 +08:00
|
|
|
|
require('./scripts/embed-packager')
|
2020-01-20 18:50:01 +08:00
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
2020-07-20 18:03:10 +08:00
|
|
|
|
env.match('{*.min.js,monaco-editor/min/**.js}', {
|
|
|
|
|
optimizer: null
|
|
|
|
|
});
|
|
|
|
|
|
2020-11-17 17:15:17 +08:00
|
|
|
|
env.match('monaco-editor/**.css', {
|
|
|
|
|
standard: false
|
|
|
|
|
});
|
|
|
|
|
|
2020-06-08 19:10:38 +08:00
|
|
|
|
fis.on('compile:optimizer', function (file) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
if (file.isJsLike && file.isMod) {
|
|
|
|
|
var contents = file.getContent();
|
|
|
|
|
|
2020-01-21 10:03:42 +08:00
|
|
|
|
// 替换 worker 地址的路径,让 sdk 加载同目录下的文件。
|
|
|
|
|
// 如果 sdk 和 worker 不是部署在一个地方,请通过指定 MonacoEnvironment.getWorkerUrl
|
2020-07-20 18:03:10 +08:00
|
|
|
|
if (
|
2022-06-07 12:45:10 +08:00
|
|
|
|
file.subpath === '/node_modules/amis-ui/lib/components/Editor.js' ||
|
2020-07-20 18:03:10 +08:00
|
|
|
|
file.subpath === '/examples/loadMonacoEditor.ts'
|
|
|
|
|
) {
|
2020-01-21 10:03:42 +08:00
|
|
|
|
contents = contents.replace(
|
|
|
|
|
/function\sfilterUrl\(url\)\s\{\s*return\s*url;/m,
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function () {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
return `var _path = '';
|
2019-08-05 16:54:39 +08:00
|
|
|
|
try {
|
2020-01-21 10:03:42 +08:00
|
|
|
|
throw new Error()
|
2019-08-05 16:54:39 +08:00
|
|
|
|
} catch (e) {
|
2021-06-24 21:38:36 +08:00
|
|
|
|
_path = (/((?:https?|file):.*?)\\n/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, '');
|
2019-08-05 16:54:39 +08:00
|
|
|
|
}
|
2020-01-21 10:03:42 +08:00
|
|
|
|
function filterUrl(url) {
|
|
|
|
|
return _path + url.substring(1);`;
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
|
|
|
|
|
file.setContent(contents);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('/examples/loader.ts', {
|
|
|
|
|
isMod: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
env.match('*', {
|
|
|
|
|
domain: '.',
|
|
|
|
|
deploy: [
|
|
|
|
|
fis.plugin('skip-packed'),
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (_, modified, total, callback) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
var i = modified.length - 1;
|
|
|
|
|
var file;
|
|
|
|
|
|
|
|
|
|
while ((file = modified[i--])) {
|
|
|
|
|
if (file.skiped || /\.map$/.test(file.subpath)) {
|
|
|
|
|
modified.splice(i + 1, 1);
|
|
|
|
|
}
|
2019-08-05 16:54:39 +08:00
|
|
|
|
}
|
2019-05-15 15:14:53 +08:00
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
i = total.length - 1;
|
|
|
|
|
while ((file = total[i--])) {
|
|
|
|
|
if (file.skiped || /\.map$/.test(file.subpath)) {
|
|
|
|
|
total.splice(i + 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-09 19:30:08 +08:00
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
callback();
|
|
|
|
|
},
|
|
|
|
|
fis.plugin('local-deliver', {
|
|
|
|
|
to: './sdk'
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
} else if (fis.project.currentMedia() === 'gh-pages') {
|
2020-12-30 20:15:06 +08:00
|
|
|
|
fis.match('*-ie11.scss', {
|
|
|
|
|
postprocessor: convertSCSSIE11
|
|
|
|
|
});
|
2020-01-20 18:50:01 +08:00
|
|
|
|
const ghPages = fis.media('gh-pages');
|
2019-05-09 19:30:08 +08:00
|
|
|
|
|
2020-11-19 19:22:56 +08:00
|
|
|
|
ghPages.match('*.scss', {
|
|
|
|
|
parser: fis.plugin('sass', {
|
|
|
|
|
sourceMap: false
|
|
|
|
|
}),
|
|
|
|
|
rExt: '.css'
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-03 12:12:14 +08:00
|
|
|
|
ghPages.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
rExt: 'js',
|
|
|
|
|
isMod: true,
|
|
|
|
|
useHash: true,
|
|
|
|
|
parser: [
|
|
|
|
|
parserMarkdown,
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (contents, file) {
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return contents.replace(
|
|
|
|
|
/\bhref=\\('|")(.+?)\\\1/g,
|
|
|
|
|
function (_, quota, link) {
|
|
|
|
|
if (/\.md($|#)/.test(link) && !/^https?\:/.test(link)) {
|
|
|
|
|
let parts = link.split('#');
|
|
|
|
|
parts[0] = parts[0].replace('.md', '');
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
'href=\\' + quota + '/amis' + parts.join('#') + '\\' + quota
|
|
|
|
|
);
|
2019-05-09 19:30:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return _;
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
2020-12-29 14:51:47 +08:00
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
2020-12-28 12:36:13 +08:00
|
|
|
|
ghPages.match(/^(\/.*)(_)(.+\.scss)$/, {
|
2020-12-25 12:35:54 +08:00
|
|
|
|
parser: [
|
|
|
|
|
parserCodeMarkdown,
|
|
|
|
|
function (contents, file) {
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return contents.replace(
|
|
|
|
|
/\bhref=\\('|")(.+?)\\\1/g,
|
|
|
|
|
function (_, quota, link) {
|
|
|
|
|
if (/\.md($|#)/.test(link) && !/^https?\:/.test(link)) {
|
|
|
|
|
let parts = link.split('#');
|
|
|
|
|
parts[0] = parts[0].replace('.md', '');
|
|
|
|
|
|
|
|
|
|
if (parts[0][0] !== '/') {
|
|
|
|
|
parts[0] = path
|
|
|
|
|
.resolve(path.dirname(file.subpath), parts[0])
|
|
|
|
|
.replace(/^\/docs/, '/amis');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 'href=\\' + quota + parts.join('#') + '\\' + quota;
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 14:51:47 +08:00
|
|
|
|
return _;
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
2020-12-29 14:51:47 +08:00
|
|
|
|
);
|
2020-12-25 12:35:54 +08:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
isMod: true,
|
|
|
|
|
rExt: '.js',
|
2020-12-28 12:36:13 +08:00
|
|
|
|
release: '$1$3'
|
2020-12-25 12:35:54 +08:00
|
|
|
|
});
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
ghPages.match('/node_modules/(**)', {
|
|
|
|
|
release: '/n/$1'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('/examples/(**)', {
|
|
|
|
|
release: '/$1'
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-16 15:38:03 +08:00
|
|
|
|
// 在爱速搭中不用 cfc,而是放 amis 目录下的路由接管
|
|
|
|
|
let cfcAddress =
|
|
|
|
|
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock';
|
|
|
|
|
if (process.env.IS_AISUDA) {
|
|
|
|
|
cfcAddress = '/amis/api';
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
ghPages.match('/{examples,docs}/**', {
|
2020-06-08 19:10:38 +08:00
|
|
|
|
preprocessor: function (contents, file) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
if (!file.isText() || typeof contents !== 'string') {
|
|
|
|
|
return contents;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-14 15:40:57 +08:00
|
|
|
|
return contents.replace(
|
|
|
|
|
/(\\?(?:'|"))((?:get|post|delete|put)\:)?\/api\/(\w+)/gi,
|
|
|
|
|
function (_, qutoa, method, path) {
|
|
|
|
|
return qutoa + (method || '') + `${cfcAddress}/` + path;
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('mock/**.{json,js,conf}', {
|
|
|
|
|
release: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('::package', {
|
|
|
|
|
packager: fis.plugin('deps-pack', {
|
|
|
|
|
'pkg/npm.js': [
|
|
|
|
|
'/examples/mod.js',
|
|
|
|
|
'node_modules/**.js',
|
|
|
|
|
'!monaco-editor/**',
|
2021-12-20 18:54:13 +08:00
|
|
|
|
'!codemirror/**',
|
2021-08-06 16:10:12 +08:00
|
|
|
|
'!mpegts.js/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!hls.js/**',
|
|
|
|
|
'!froala-editor/**',
|
2021-11-01 15:59:37 +08:00
|
|
|
|
|
2020-04-15 16:27:38 +08:00
|
|
|
|
'!tinymce/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!zrender/**',
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'!echarts/**',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'!echarts-stat/**',
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'!papaparse/**',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'!exceljs/**',
|
|
|
|
|
'!docsearch.js/**',
|
|
|
|
|
'!monaco-editor/**.css',
|
|
|
|
|
'!src/components/RichText.tsx',
|
|
|
|
|
'!src/components/Tinymce.tsx',
|
|
|
|
|
'!src/components/ColorPicker.tsx',
|
|
|
|
|
'!react-color/**',
|
|
|
|
|
'!material-colors/**',
|
|
|
|
|
'!reactcss/**',
|
|
|
|
|
'!tinycolor2/**',
|
|
|
|
|
'!cropperjs/**',
|
|
|
|
|
'!react-cropper/**',
|
2022-01-28 16:01:02 +08:00
|
|
|
|
'!jsbarcode/**',
|
|
|
|
|
'!src/components/BarCode.tsx',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'!src/lib/renderers/Form/CityDB.js',
|
|
|
|
|
'!src/components/Markdown.tsx',
|
|
|
|
|
'!src/utils/markdown.ts',
|
|
|
|
|
'!highlight.js/**',
|
|
|
|
|
'!entities/**',
|
|
|
|
|
'!linkify-it/**',
|
|
|
|
|
'!mdurl/**',
|
|
|
|
|
'!uc.micro/**',
|
|
|
|
|
'!markdown-it/**',
|
|
|
|
|
'!markdown-it-html5-media/**',
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'!punycode/**',
|
|
|
|
|
'!amis-formula/**',
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'!fflate/**',
|
2023-03-20 20:09:13 +08:00
|
|
|
|
'!office-viewer/**',
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'!amis-core/**',
|
|
|
|
|
'!amis-ui/**',
|
2022-06-06 23:21:30 +08:00
|
|
|
|
'!amis/**'
|
2020-01-20 18:50:01 +08:00
|
|
|
|
],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2022-06-06 23:21:30 +08:00
|
|
|
|
'pkg/rich-text.js': [
|
|
|
|
|
'amis-ui/lib/components/RichText.js',
|
|
|
|
|
'froala-editor/**'
|
|
|
|
|
],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'pkg/tinymce.js': ['amis-ui/lib/components/Tinymce.tsx', 'tinymce/**'],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2021-12-20 18:54:13 +08:00
|
|
|
|
'pkg/codemirror.js': ['codemirror/**'],
|
|
|
|
|
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'pkg/papaparse.js': ['papaparse/**'],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'pkg/exceljs.js': ['exceljs/**'],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'pkg/barcode.js': ['amis-ui/lib/components/BarCode.tsx', 'jsbarcode/**'],
|
2022-01-28 16:01:02 +08:00
|
|
|
|
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'pkg/markdown.js': [
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'amis-ui/lib/components/Markdown.tsx',
|
|
|
|
|
'amis-core/lib/utils/markdown.ts',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'highlight.js/**',
|
|
|
|
|
'entities/**',
|
|
|
|
|
'linkify-it/**',
|
|
|
|
|
'mdurl/**',
|
|
|
|
|
'uc.micro/**',
|
|
|
|
|
'markdown-it/**',
|
|
|
|
|
'markdown-it-html5-media/**',
|
|
|
|
|
'punycode/**'
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'pkg/color-picker.js': [
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'amis-ui/lib/components/ColorPicker.tsx',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'react-color/**',
|
|
|
|
|
'material-colors/**',
|
|
|
|
|
'reactcss/**',
|
|
|
|
|
'tinycolor2/**'
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'pkg/cropperjs.js': ['cropperjs/**', 'react-cropper/**'],
|
|
|
|
|
|
|
|
|
|
'pkg/charts.js': ['zrender/**', 'echarts/**', 'echarts-stat/**'],
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'pkg/api-mock.js': ['mock/*.ts'],
|
2021-09-23 12:34:34 +08:00
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'pkg/app.js': [
|
2020-07-31 12:40:04 +08:00
|
|
|
|
'/examples/components/App.tsx',
|
|
|
|
|
'/examples/components/App.tsx:deps'
|
2020-01-20 18:50:01 +08:00
|
|
|
|
],
|
|
|
|
|
|
2020-12-17 18:16:29 +08:00
|
|
|
|
'pkg/echarts-editor.js': [
|
|
|
|
|
'/examples/components/EChartsEditor/*.tsx',
|
|
|
|
|
'!/examples/components/EChartsEditor/Example.tsx',
|
|
|
|
|
'!/examples/components/EChartsEditor/Common.tsx'
|
|
|
|
|
],
|
|
|
|
|
|
2023-03-20 22:54:42 +08:00
|
|
|
|
'pkg/office-viewer.js': ['office-viewer/**', 'fflate/**'],
|
|
|
|
|
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'pkg/rest.js': [
|
|
|
|
|
'**.{js,jsx,ts,tsx}',
|
|
|
|
|
'!monaco-editor/**',
|
2021-08-06 16:10:12 +08:00
|
|
|
|
'!mpegts.js/**',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!hls.js/**',
|
|
|
|
|
'!froala-editor/**',
|
2021-11-01 15:59:37 +08:00
|
|
|
|
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'!amis-ui/lib/components/RichText.tsx',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'!zrender/**',
|
2020-09-25 18:06:14 +08:00
|
|
|
|
'!echarts/**',
|
2020-11-17 16:05:16 +08:00
|
|
|
|
'!papaparse/**',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'!exceljs/**',
|
2022-06-06 11:58:24 +08:00
|
|
|
|
'!amis-core/lib/utils/markdown.ts',
|
2021-09-23 12:34:34 +08:00
|
|
|
|
'!highlight.js/**',
|
|
|
|
|
'!argparse/**',
|
|
|
|
|
'!entities/**',
|
|
|
|
|
'!linkify-it/**',
|
|
|
|
|
'!mdurl/**',
|
|
|
|
|
'!uc.micro/**',
|
|
|
|
|
'!markdown-it/**',
|
|
|
|
|
'!markdown-it-html5-media/**'
|
2020-01-20 18:50:01 +08:00
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'pkg/npm.css': ['node_modules/*/**.css', '!monaco-editor/**'],
|
|
|
|
|
|
|
|
|
|
// css 打包
|
|
|
|
|
'pkg/style.css': [
|
|
|
|
|
'*.scss',
|
|
|
|
|
'*.css',
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'!scss/themes/*.scss',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
// 要切换主题,不能打在一起。'/scss/*.scss',
|
|
|
|
|
'!/examples/style.scss',
|
2020-07-20 18:03:10 +08:00
|
|
|
|
'!monaco-editor/**',
|
2022-06-07 12:45:10 +08:00
|
|
|
|
'!scss/helper.scss',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
'/examples/style.scss' // 让它在最下面
|
|
|
|
|
]
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
postpackager: [
|
|
|
|
|
fis.plugin('loader', {
|
|
|
|
|
useInlineMap: false,
|
|
|
|
|
resourceType: 'mod'
|
|
|
|
|
}),
|
2020-06-08 19:10:38 +08:00
|
|
|
|
function (ret) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
const indexHtml = ret.src['/examples/index.html'];
|
2020-07-30 20:23:46 +08:00
|
|
|
|
const appJs = ret.src['/examples/components/App.tsx'];
|
|
|
|
|
const DocJs = ret.src['/examples/components/Doc.tsx'];
|
2021-01-04 23:36:39 +08:00
|
|
|
|
const DocNavCN = ret.src['/examples/components/DocNavCN.ts'];
|
2021-02-02 09:55:03 +08:00
|
|
|
|
const Components = ret.src['/examples/components/Components.tsx'];
|
2020-12-11 12:10:01 +08:00
|
|
|
|
const DocCSS = ret.src['/examples/components/CssDocs.tsx'];
|
2021-12-22 12:37:45 +08:00
|
|
|
|
const ExampleJs = ret.src['/examples/components/Example.jsx'];
|
2020-01-20 18:50:01 +08:00
|
|
|
|
|
|
|
|
|
const pages = [];
|
2020-07-31 12:40:04 +08:00
|
|
|
|
const source = [
|
|
|
|
|
appJs.getContent(),
|
|
|
|
|
DocJs.getContent(),
|
2021-01-04 23:36:39 +08:00
|
|
|
|
DocNavCN.getContent(),
|
2021-02-02 09:55:03 +08:00
|
|
|
|
Components.getContent(),
|
2020-12-11 12:10:01 +08:00
|
|
|
|
DocCSS.getContent(),
|
2020-07-31 12:40:04 +08:00
|
|
|
|
ExampleJs.getContent()
|
|
|
|
|
].join('\n');
|
2020-12-29 14:51:47 +08:00
|
|
|
|
source.replace(
|
|
|
|
|
/\bpath\b\s*\:\s*('|")(.*?)\1/g,
|
|
|
|
|
function (_, qutoa, path) {
|
|
|
|
|
if (path === '*') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-29 14:28:49 +08:00
|
|
|
|
|
2020-12-29 14:51:47 +08:00
|
|
|
|
pages.push(path.replace(/^\//, ''));
|
|
|
|
|
return _;
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-01-20 18:50:01 +08:00
|
|
|
|
|
|
|
|
|
const contents = indexHtml.getContent();
|
2020-06-08 19:10:38 +08:00
|
|
|
|
pages.forEach(function (path) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
const file = fis.file(
|
|
|
|
|
fis.project.getProjectPath(),
|
|
|
|
|
'/examples/' + path + '.html'
|
|
|
|
|
);
|
|
|
|
|
file.setContent(contents);
|
|
|
|
|
ret.pkg[file.getId()] = file;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('*.{css,less,scss}', {
|
2020-12-11 12:10:01 +08:00
|
|
|
|
optimizer: [
|
2020-12-17 18:16:29 +08:00
|
|
|
|
function (contents) {
|
2020-12-11 12:10:01 +08:00
|
|
|
|
if (typeof contents === 'string') {
|
|
|
|
|
contents = contents.replace(/\/\*\!markdown[\s\S]*?\*\//g, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return contents;
|
|
|
|
|
},
|
|
|
|
|
fis.plugin('clean-css')
|
|
|
|
|
],
|
2020-01-20 18:50:01 +08:00
|
|
|
|
useHash: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('::image', {
|
|
|
|
|
useHash: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('*.{js,ts,tsx,jsx}', {
|
2021-04-06 10:50:17 +08:00
|
|
|
|
optimizer: fis.plugin('terser'),
|
2020-01-20 18:50:01 +08:00
|
|
|
|
useHash: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ghPages.match('*.map', {
|
|
|
|
|
release: false,
|
|
|
|
|
url: 'null',
|
|
|
|
|
useHash: false
|
|
|
|
|
});
|
2022-02-09 11:18:32 +08:00
|
|
|
|
ghPages.match('{*.jsx,*.tsx,*.ts,/examples/**.js,}', {
|
2020-06-08 19:10:38 +08:00
|
|
|
|
moduleId: function (m, path) {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
return fis.util.md5('amis' + path);
|
|
|
|
|
},
|
2020-04-16 10:56:33 +08:00
|
|
|
|
parser: [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
// docsGennerator,
|
2020-04-16 10:56:33 +08:00
|
|
|
|
fis.plugin('typescript', {
|
|
|
|
|
sourceMap: false,
|
|
|
|
|
importHelpers: true,
|
|
|
|
|
esModuleInterop: true
|
2020-12-03 13:07:58 +08:00
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
function (contents) {
|
|
|
|
|
return contents
|
2020-12-29 14:51:47 +08:00
|
|
|
|
.replace(
|
|
|
|
|
/(?:\w+\.)?\b__uri\s*\(\s*('|")(.*?)\1\s*\)/g,
|
|
|
|
|
function (_, quote, value) {
|
|
|
|
|
let str = quote + value + quote;
|
|
|
|
|
return (
|
|
|
|
|
'(function(){try {return __uri(' +
|
|
|
|
|
str +
|
|
|
|
|
')} catch(e) {return ' +
|
|
|
|
|
str +
|
|
|
|
|
'}})()'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
2021-09-01 11:19:49 +08:00
|
|
|
|
.replace(/\(\d+, (tslib_\d+\.__importStar)\)/g, '$1')
|
2020-12-03 13:07:58 +08:00
|
|
|
|
.replace(
|
|
|
|
|
/return\s+(tslib_\d+)\.__importStar\(require\(('|")(.*?)\2\)\);/g,
|
|
|
|
|
function (_, tslib, quto, value) {
|
|
|
|
|
return `return new Promise(function(resolve){require(['${value}'], function(ret) {resolve(${tslib}.__importStar(ret));})});`;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-16 10:56:33 +08:00
|
|
|
|
]
|
2020-01-20 18:50:01 +08:00
|
|
|
|
});
|
|
|
|
|
ghPages.match('*', {
|
2020-08-27 11:11:50 +08:00
|
|
|
|
domain: '/amis',
|
2020-01-20 18:50:01 +08:00
|
|
|
|
deploy: [
|
|
|
|
|
fis.plugin('skip-packed'),
|
|
|
|
|
fis.plugin('local-deliver', {
|
|
|
|
|
to: './gh-pages'
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
});
|
2020-07-20 18:03:10 +08:00
|
|
|
|
ghPages.match('{*.min.js,monaco-editor/min/**.js}', {
|
2020-01-20 18:50:01 +08:00
|
|
|
|
optimizer: null
|
|
|
|
|
});
|
2020-08-21 15:13:39 +08:00
|
|
|
|
ghPages.match('docs.json', {
|
|
|
|
|
domain: null
|
|
|
|
|
});
|
2019-04-30 11:11:25 +08:00
|
|
|
|
}
|