amis2/fis-conf.js
吴多益 3a7daf0f90
feat: office-viewer Word 文档渲染 (#6412) (#6415)
* init

* theme

* 基础文本渲染

* 基础文本样式

* 支持简单链接和图片

* 修复 jc 解析不正确问题

* 解析和渲染分离

* 初步支持列表渲染

* 完善样式表的实现

* 表格解析初步

* 避免解析顺序不一致

* 避免解析顺序不一致导致的问题

* 基于 DOMParser 来实现解析; 初步实现表格渲染

* 修复行高解析不正确问题

* 修复变量替换不正确问题

* 补充注释

* 用 fflate 替换 jszip, 支持同步使用

* 支持渲染 tab

* 支持表格条件渲染

* 优化表格样式适配

* 完善背景色支持

* 支持 ruby

* 支持简单 inserttext

* 修复表格合并不正确问题

* amis 渲染初步

* 整合 amis 初步

* 支持 input-file 上传预览

* styles: 优化button组件单icon情况的样式 (#6269)



* fix: Badge设置overflowCount不生效问题修复 (#6267)



* feat: InputGroup报错展示优化 (#5803)

* feat:增加DATETOWEEK表达式

* feat:增加DATETOWEEK表达式

* feat:增加WEEKDAY和WEEK表达式

* feat:增加WEEKDAY和WEEK表达式

* feat:增加WEEKDAY和WEEK表达式

* feat:增加WEEKDAY和WEEK表达式

* feat:增加WEEKDAY和WEEK表达式

* chore: 2.7.3版本改为2.8.0 (#6272)

* styles: 输入框附加组件样式 (#6271)



* styles: 优化checkbox组件选中态样式 (#6277)



* feat:增加判断日期范围的表达式BETWEENRANGE&&优化STARTOF和ENDOF

* docs:表达式文档 (#6282)

* fix: Nav样式问题、性能优化 (#6280)



* chore: 还原几个 antd 导航及表格的颜色 (#6276)

* chore: Action倒计时key添加id避免冲突 (#5943)

* fix: nav同层拖拽问题修复 (#6285)



* v2.8.0

* chore: 删除在 ts 编译后永远都不会成立的代码 (#6291)

* styles: 将组件透明背景颜色改为白色 (#6289)

* styles: 将组件透明背景颜色改为白色

* styles: 将组件透明背景颜色改为白色

---------



* fix: Select组件overlay属性在popOverContainer时宽度错误问题 (#6284)

* fix:Select组件overlay属性在popOverContainer时宽度错误问题

* 问题修改

* styles: 优化link组件svg图标样式 (#6292)



* chore: Tree 组件中使用 value 替换 key (#6194)

* fix: 单选选项值包含逗号时获取选项错误问题 (#6258)

* fix: 单选选项值包含逗号时获取选项错误问题

* 加个单测

* 单测问题

* 在WrapControl 中使渲染器默认 multiple 生效

* 修改

* fix: select 各种模式支持 checkAll (#5941)

* feat(页面交互行为跟踪): 新增pageLoaded事件 (#6299)

* fix: nav拖拽卡顿、更多操作打开定位等问题修复 (#6304)



* fix: toast组件css变量拼错 (#6302)



* fix: CRUD2 加载更多时接口page传参始终为1 (#6298)

* fix: 日期范围底部按钮居中 (#6301)

* 调整 saveAs  fileName 优先级

* feat: 移动端人员选择增加确定按钮

* Update UserSelect.tsx

* fix: 人员选择ts 类型错误

* fix: 城市选择组件移动端回显问题

* fix: 移动端级联选择器选中值bug修复

* Update Cascader.tsx

* fix: 城市选择香港、澳门不能选择市

* fix: 删除错误城市数据

* feat: 移动端人员选择支持字段配置

* feat: 人员选择组件支持字段配置

* Update UserSelect.tsx

* fix: 移动端人员选择静态展示头像url回显

* fix: 日期时间选择器底部按钮居中

---------



* fix: table2全选、嵌套展开等问题修复 (#6313)



* docs(API 适配器): 调整文档细节 (#6314)

* styles: 优化清除图标样式 (#6312)



* fix: 修复 Tree 在传入 pathSeparator 时,非根节点无法选中 (#6315)

* Update README.md

* fix: 解决因部分组件默认配置,导致编辑器配置面板宽度溢出问题 (#6328)



* chore: svg 瘦身 (#6320)

* chore: svg 瘦身

* chore: svg 瘦身

* chore: svg 瘦身

* feat: mapping 的 source 接口支持 select 选项类接口 (#6326)

* fix: 调整 spinner-overlay 和 dialog 的 z-index,使关闭按钮不会被 spinner 遮挡 (#6321)

* feat: 新增 number 组件用来展示数字 (#6330)

* feat: 新增 number 组件用来展示数字

* feat: 新增 number 组件用来展示数字

* chore: tableCell 内部属性换个名字,以免跟已有其他组件组合使用时冲突

* fix: 注销renderer问题 (#6327)



* feat: InputExcel支持placeholder (#6295)

* feat: button-group-select支持角标 (#6309)



* chore: 暴露 InputBoxWithSuggestion (#6337)

* fix: 注销renderer问题 (#6338)



* docs: 补充trackExpression用法示例 (#6286)

* fix: 解决monaco环境变量和monaco插件的冲突 (#6283)



* fix: Cards嵌套List组件时, props透传导致Schema不生效问题 (#6110)

* styles: 优化带单位的number组件样式 (#6054)

* styles: 优化待单位的number组件样式

* 更新快照

---------



* fix(Table): #2978 嵌套表格如何设置默认全部展开 (#6028)

* fix(Table): #2978 嵌套表格如何设置默认全部展开

* fix(Table): #2978 更改函数命名

* fix: now表达式作为form组件默认值时,增加特殊逻辑,处理数据更新 (#5783)

* fix: 解决公式编辑器 搜索变量失效bug (#6345)



* fix: nav角标、悬浮展开子菜单、更多操作不可点击等问题修复 (#6346)



* feat:config动作优化

* fix: 修复卡片的 checkOnItemClick 配置问题 (#6365)

* fix: 修复弹窗中 form 配置 closeDialogOnSubmit 无效的问题 (#6368)

* fix: Transfer tree mode 支持 onlyChildren;两个值为undefined的Option不相等 (#6342)

* fix:transfer tree 支持 onlyChildren;两个值为undefined的Option不相等

* 修改

* 修改

* feat:carousel支持卡片动画模式 (#6354)

* feat:carousel支持多图配置

* Update carousel.md

---------




* fix: inputTable 组件value依赖别的字段时,不同步数据域的问题 (#6360)

* fix: inputTable 组件value依赖别的字段时,不同步数据域的问题

* 修改

* 修改

* feat: 添加input-table子表单校验 (#6357)

* feat: 添加input-table子表单校验

* feat: 添加input-table snapshots更新

* feat: 添加input-table子表单校验

* feat: 添加input-table子表单校验

* feat: 添加input-table子表单校验

* feat: input-table snapshots更新

* feat: 添加input-table子表单校验

* feat: 添加input-table子表单校验

* feat: Steps source支持动态获取value status (#6370)

* fix: 修复 drawer reload 目标可能找不到的问题 (#6373)

* fix: 修复 crud 嵌套会触发多次快速保存接口问题 (#6374)

* fix: 修复 this.model.validated 可能读取不到的报错 (#6375)

* chore: alert 支持多个实例

* feat: Tag支持事件动作 (#6325)

* feat: reload 支持动态目标, 解决目标在循环中场景 (#6372)

* chore: Select组件checkAllBySearch默认为true (#6347)

* fix: Nav切换数据源实时更新、点击分组卡顿、横向模式排序等问题修复 (#6371)



* fix: table单元格支持自定义样式、crud支持本地数据快速过滤 (#6353)



* fix: 修改角标样式 (#6383)



* fix: 图标选择器,如果图标不属于saas项目中的,则默认显示schema配置的内容 (#6394)



* feat: icon支持自定义样式 (#6379)



* fix: 解决input-table某些场景下无法新增的bug (#6400)



* fix: 解决input-table某些场景下无法新增的bug (#6404)



* fix: input-table内columns为下拉框时,删掉下拉框的选中值,发现input-table的数据域更新错误 (#6402)

* fix: input-table内columns为下拉框时,删掉下拉框的选中值,发现input-table的数据域更新错误

* fix: input-table内columns为下拉框时,删掉下拉框的选中值,发现input-table的数据域更新错误

* 修复示例文档错误

* 修复用例报错

* 修复 fis 报错

---------

Co-authored-by: qkiroc <30946345+qkiroc@users.noreply.github.com>
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
Co-authored-by: wanglinfang2014 <w.l.fang@foxmail.com>
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
Co-authored-by: lvxiaojiao <lvxiaojiao@baidu.com>
Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
Co-authored-by: lurunze1226 <lurunze1226@foxmail.com>
Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
Co-authored-by: sansiro <sansiro@sansiro.me>
Co-authored-by: meerkat <kit_hack@outlook.com>
Co-authored-by: 刘丹 <365533093@qq.com>
Co-authored-by: backpast <agileago@gmail.com>
Co-authored-by: renjianhua <renjianhua@zuoshouyisheng.com>
Co-authored-by: ls <1769057083@qq.com>
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
Co-authored-by: zhangzhulei <30931358+DynaZhang@users.noreply.github.com>
Co-authored-by: zhangzhulei <zhangzhulei@baidu.com>
Co-authored-by: gooolh <57032082+gooolh@users.noreply.github.com>
Co-authored-by: liujintao03 <liujintao03@baidu.com>
Co-authored-by: Dora <53067150+Dora-boots@users.noreply.github.com>
Co-authored-by: yanglu19 <yanglu19@baidu.com>
Co-authored-by: TommyShao <tomieric@gmail.com>
Co-authored-by: pianruijie <13522335863@163.com>
Co-authored-by: xiangwaner <1186355501@qq.com>
Co-authored-by: zhaowenli <zhaowenli@baidu.com>
Co-authored-by: zhou999 <zhousq809@163.com>
Co-authored-by: Allen <yupeng.fe@qq.com>
Co-authored-by: sarding <37691952+sarding@users.noreply.github.com>
Co-authored-by: sarding <hongfuquan@baidu.com>
2023-03-20 22:54:42 +08:00

1012 lines
25 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file fis-conf.js 配置
*/
const path = require('path');
const fs = require('fs');
const package = require('./packages/amis/package.json');
const parserMarkdown = require('./scripts/md-parser');
const convertSCSSIE11 = require('./scripts/scss-ie11');
const parserCodeMarkdown = require('./scripts/code-md-parser');
fis.set('project.ignore', [
'public/**',
'scripts/**',
'npm/**',
'gh-pages/**',
'.*/**',
'node_modules/**'
]);
// 配置只编译哪些文件。
const Resource = fis.require('postpackager-loader/lib/resource.js');
const versionHash = fis.util.md5(package.version);
Resource.extend({
buildResourceMap: function () {
const resourceMap = this.__super();
if (resourceMap === '') {
return '';
}
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)});`;
},
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;
}
});
}
});
fis.set('project.files', [
'schema.json',
'/examples/map.json',
'/scss/helper.scss',
'/scss/themes/*.scss',
'/examples/*.html',
'/examples/app/*.html',
'/examples/*.tpl',
'/examples/static/*.png',
'/examples/static/*.svg',
'/examples/static/*.jpg',
'/examples/static/*.jpeg',
'/examples/static/*.docx',
'/examples/static/photo/*.jpeg',
'/examples/static/photo/*.png',
'/examples/static/audio/*.mp3',
'/examples/static/video/*.mp4',
'mock/**'
]);
fis.match('/schema.json', {
release: '/$0'
});
fis.match('/mock/**', {
useCompile: false
});
fis.match('mod.js', {
useCompile: false
});
fis.match('*.scss', {
parser: fis.plugin('sass', {
sourceMap: true
}),
rExt: '.css'
});
fis.match('icons/**.svg', {
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
})
]
});
fis.match('/node_modules/**.js', {
isMod: true
});
fis.match('tinymce/{tinymce.js,plugins/**.js,themes/silver/theme.js}', {
ignoreDependencies: true
});
fis.match('tinymce/plugins/*/index.js', {
ignoreDependencies: false
});
fis.match(/(?:mpegts\.js|object\-inspect\/util\.inspect\.js)/, {
ignoreDependencies: true
});
fis.match('monaco-editor/min/**.js', {
isMod: false,
ignoreDependencies: true
});
fis.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
rExt: 'js',
ignoreDependencies: true,
parser: [
parserMarkdown,
function (contents, file) {
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;
}
return _;
}
);
}
],
isMod: true
});
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);
}
}
});
fis.match('{*.ts,*.jsx,*.tsx,/examples/**.js,/src/**.js,/src/**.ts}', {
parser: [
// docsGennerator,
fis.plugin('typescript', {
importHelpers: true,
esModuleInterop: true,
experimentalDecorators: true,
inlineSourceMap: true,
target: 4
}),
function (content) {
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));})})`;
}
)
);
}
],
preprocessor: fis.plugin('js-require-css'),
isMod: true,
rExt: '.js'
});
fis.match('markdown-it/**', {
preprocessor: fis.plugin('js-require-file')
});
fis.match('*.html:jsx', {
parser: fis.plugin('typescript'),
rExt: '.js',
isMod: false
});
// 这些用了 esm
fis.match(
'{echarts/extension/**.js,zrender/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js,axios/**.js}',
{
parser: fis.plugin('typescript', {
sourceMap: false,
importHelpers: true,
esModuleInterop: true,
emitDecoratorMetadata: false,
experimentalDecorators: false
})
}
);
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)) {
newName = `/packages/amis-ui/scss/themes/${RegExp.$1}.scss`;
} else if (/^amis\/lib\/(.*)\.css$/.test(uri)) {
newName = `/packages/amis-ui/scss/${RegExp.$1}.scss`;
} 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}\` 找不到`);
}
}
});
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))
);
}
});
}
fis.unhook('components');
fis.hook('node_modules', {
shimProcess: false,
shimGlobal: false,
shimBuffer: false
// shutup: true
});
fis.hook('commonjs', {
sourceMap: false,
extList: ['.js', '.jsx', '.tsx', '.ts'],
paths: {
'monaco-editor': '/examples/loadMonacoEditor'
}
});
fis.match('_*.scss', {
release: false
});
fis.media('dev').match('_*.scss', {
parser: [
parserCodeMarkdown,
function (contents, file) {
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;
}
return _;
}
);
}
],
release: '$0',
isMod: true,
rExt: '.js'
});
fis.media('dev').match('::package', {
postpackager: fis.plugin('loader', {
useInlineMap: false,
resourceType: 'mod'
})
});
fis.media('dev').match('/node_modules/**.js', {
packTo: '/pkg/npm.js'
});
fis.match('{monaco-editor,amis,amis-core}/**', {
packTo: null
});
if (fis.project.currentMedia() === 'publish-sdk') {
const env = fis.media('publish-sdk');
fis.on('compile:end', function (file) {
if (
file.subpath === '/packages/amis/src/index.tsx' ||
file.subpath === '/examples/mod.js' ||
file.subpath === '/examples/loader.ts'
) {
file.setContent(file.getContent().replace(/@version/g, package.version));
} else if (file.subpath === '/packages/amis-core/src/index.tsx') {
file.setContent(
file
.getContent()
.replace(/__buildVersion/g, JSON.stringify(package.version))
);
}
});
env.get('project.ignore').push('sdk/**');
env.set('project.files', ['examples/sdk-placeholder.html']);
env.match('/{examples,scss,src}/(**)', {
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', {
parser: fis.plugin('sass', {
sourceMap: false
})
});
env.match('{*.ts,*.jsx,*.tsx,/examples/**.js,/src/**.js,/src/**.ts}', {
parser: [
// docsGennerator,
fis.plugin('typescript', {
importHelpers: true,
esModuleInterop: true,
experimentalDecorators: true,
sourceMap: false
}),
function (content) {
return content
.replace(/\b[a-zA-Z_0-9$]+\.__uri\s*\(/g, '__uri(')
.replace(/\(\d+, (tslib_\d+\.__importStar)\)/g, '$1')
.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));})});`;
}
);
}
],
preprocessor: fis.plugin('js-require-css'),
isMod: true,
rExt: '.js'
});
env.match('/examples/mod.js', {
isMod: false,
optimizer: fis.plugin('terser')
});
env.match('*.{js,jsx,ts,tsx}', {
optimizer: fis.plugin('terser'),
moduleId: function (m, path) {
return fis.util.md5(package.version + 'amis-sdk' + path);
}
});
env.match('::package', {
packager: fis.plugin('deps-pack', {
'sdk.js': [
'examples/mod.js',
'examples/embed.tsx',
'examples/embed.tsx:deps',
'examples/loadMonacoEditor.ts',
'!mpegts.js/**',
'!hls.js/**',
'!froala-editor/**',
'!codemirror/**',
'!tinymce/**',
'!zrender/**',
'!echarts/**',
'!echarts-stat/**',
'!papaparse/**',
'!exceljs/**',
'!docsearch.js/**',
'!monaco-editor/**.css',
'!amis-ui/lib/components/RichText.js',
'!amis-ui/lib/components/Tinymce.js',
'!amis-ui/lib/components/ColorPicker.js',
'!react-color/**',
'!material-colors/**',
'!reactcss/**',
'!tinycolor2/**',
'!cropperjs/**',
'!react-cropper/**',
'!jsbarcode/**',
'!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',
'!highlight.js/**',
'!entities/**',
'!linkify-it/**',
'!mdurl/**',
'!uc.micro/**',
'!markdown-it/**',
'!markdown-it-html5-media/**',
'!punycode/**',
'!office-viewer/**',
'!fflate/**'
],
'rich-text.js': [
'amis-ui/lib/components/RichText.js',
'froala-editor/**'
],
'tinymce.js': ['amis-ui/lib/components/Tinymce.js', 'tinymce/**'],
'codemirror.js': ['codemirror/**'],
'papaparse.js': ['papaparse/**'],
'exceljs.js': ['exceljs/**'],
'markdown.js': [
'amis-ui/lib/components/Markdown.js',
'highlight.js/**',
'entities/**',
'linkify-it/**',
'mdurl/**',
'uc.micro/**',
'markdown-it/**',
'markdown-it-html5-media/**',
'punycode/**'
],
'color-picker.js': [
'amis-ui/lib/components/ColorPicker.js',
'react-color/**',
'material-colors/**',
'reactcss/**',
'tinycolor2/**'
],
'cropperjs.js': ['cropperjs/**', 'react-cropper/**'],
'barcode.js': ['src/components/BarCode.tsx', 'jsbarcode/**'],
'charts.js': ['zrender/**', 'echarts/**', 'echarts-stat/**'],
'office-viewer.js': ['office-viewer/**', 'fflate/**'],
'rest.js': [
'*.js',
'!monaco-editor/**',
'!codemirror/**',
'!mpegts.js/**',
'!hls.js/**',
'!froala-editor/**',
'!amis-ui/lib/components/RichText.js',
'!zrender/**',
'!echarts/**',
'!papaparse/**',
'!exceljs/**',
'!highlight.js/**',
'!argparse/**',
'!entities/**',
'!linkify-it/**',
'!mdurl/**',
'!uc.micro/**',
'!markdown-it/**',
'!markdown-it-html5-media/**',
'!office-viewer/**',
'!fflate/**'
]
}),
postpackager: [
fis.plugin('loader', {
useInlineMap: false,
resourceType: 'mod'
}),
require('./scripts/embed-packager')
]
});
env.match('{*.min.js,monaco-editor/min/**.js}', {
optimizer: null
});
env.match('monaco-editor/**.css', {
standard: false
});
fis.on('compile:optimizer', function (file) {
if (file.isJsLike && file.isMod) {
var contents = file.getContent();
// 替换 worker 地址的路径,让 sdk 加载同目录下的文件。
// 如果 sdk 和 worker 不是部署在一个地方,请通过指定 MonacoEnvironment.getWorkerUrl
if (
file.subpath === '/node_modules/amis-ui/lib/components/Editor.js' ||
file.subpath === '/examples/loadMonacoEditor.ts'
) {
contents = contents.replace(
/function\sfilterUrl\(url\)\s\{\s*return\s*url;/m,
function () {
return `var _path = '';
try {
throw new Error()
} catch (e) {
_path = (/((?:https?|file):.*?)\\n/.test(e.stack) && RegExp.$1).replace(/\\/[^\\/]*$/, '');
}
function filterUrl(url) {
return _path + url.substring(1);`;
}
);
file.setContent(contents);
}
}
});
env.match('/examples/loader.ts', {
isMod: false
});
env.match('*', {
domain: '.',
deploy: [
fis.plugin('skip-packed'),
function (_, modified, total, callback) {
var i = modified.length - 1;
var file;
while ((file = modified[i--])) {
if (file.skiped || /\.map$/.test(file.subpath)) {
modified.splice(i + 1, 1);
}
}
i = total.length - 1;
while ((file = total[i--])) {
if (file.skiped || /\.map$/.test(file.subpath)) {
total.splice(i + 1, 1);
}
}
callback();
},
fis.plugin('local-deliver', {
to: './sdk'
})
]
});
} else if (fis.project.currentMedia() === 'gh-pages') {
fis.match('*-ie11.scss', {
postprocessor: convertSCSSIE11
});
const ghPages = fis.media('gh-pages');
ghPages.match('*.scss', {
parser: fis.plugin('sass', {
sourceMap: false
}),
rExt: '.css'
});
ghPages.match('{/docs,/packages/amis-ui/scss/helper}/**.md', {
rExt: 'js',
isMod: true,
useHash: true,
parser: [
parserMarkdown,
function (contents, file) {
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
);
}
return _;
}
);
}
]
});
ghPages.match(/^(\/.*)(_)(.+\.scss)$/, {
parser: [
parserCodeMarkdown,
function (contents, file) {
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;
}
return _;
}
);
}
],
isMod: true,
rExt: '.js',
release: '$1$3'
});
ghPages.match('/node_modules/(**)', {
release: '/n/$1'
});
ghPages.match('/examples/(**)', {
release: '/$1'
});
// 在爱速搭中不用 cfc而是放 amis 目录下的路由接管
let cfcAddress =
'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock';
if (process.env.IS_AISUDA) {
cfcAddress = '/amis/api';
}
ghPages.match('/{examples,docs}/**', {
preprocessor: function (contents, file) {
if (!file.isText() || typeof contents !== 'string') {
return contents;
}
return contents.replace(
/(\\?(?:'|"))((?:get|post|delete|put)\:)?\/api\/(\w+)/gi,
function (_, qutoa, method, path) {
return qutoa + (method || '') + `${cfcAddress}/` + path;
}
);
}
});
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/**',
'!codemirror/**',
'!mpegts.js/**',
'!hls.js/**',
'!froala-editor/**',
'!tinymce/**',
'!zrender/**',
'!echarts/**',
'!echarts-stat/**',
'!papaparse/**',
'!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/**',
'!jsbarcode/**',
'!src/components/BarCode.tsx',
'!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/**',
'!punycode/**',
'!amis-formula/**',
'!fflate/**',
'!office-viewer/**',
'!amis-core/**',
'!amis-ui/**',
'!amis/**'
],
'pkg/rich-text.js': [
'amis-ui/lib/components/RichText.js',
'froala-editor/**'
],
'pkg/tinymce.js': ['amis-ui/lib/components/Tinymce.tsx', 'tinymce/**'],
'pkg/codemirror.js': ['codemirror/**'],
'pkg/papaparse.js': ['papaparse/**'],
'pkg/exceljs.js': ['exceljs/**'],
'pkg/barcode.js': ['amis-ui/lib/components/BarCode.tsx', 'jsbarcode/**'],
'pkg/markdown.js': [
'amis-ui/lib/components/Markdown.tsx',
'amis-core/lib/utils/markdown.ts',
'highlight.js/**',
'entities/**',
'linkify-it/**',
'mdurl/**',
'uc.micro/**',
'markdown-it/**',
'markdown-it-html5-media/**',
'punycode/**'
],
'pkg/color-picker.js': [
'amis-ui/lib/components/ColorPicker.tsx',
'react-color/**',
'material-colors/**',
'reactcss/**',
'tinycolor2/**'
],
'pkg/cropperjs.js': ['cropperjs/**', 'react-cropper/**'],
'pkg/charts.js': ['zrender/**', 'echarts/**', 'echarts-stat/**'],
'pkg/api-mock.js': ['mock/*.ts'],
'pkg/app.js': [
'/examples/components/App.tsx',
'/examples/components/App.tsx:deps'
],
'pkg/echarts-editor.js': [
'/examples/components/EChartsEditor/*.tsx',
'!/examples/components/EChartsEditor/Example.tsx',
'!/examples/components/EChartsEditor/Common.tsx'
],
'pkg/office-viewer.js': ['office-viewer/**', 'fflate/**'],
'pkg/rest.js': [
'**.{js,jsx,ts,tsx}',
'!monaco-editor/**',
'!mpegts.js/**',
'!hls.js/**',
'!froala-editor/**',
'!amis-ui/lib/components/RichText.tsx',
'!zrender/**',
'!echarts/**',
'!papaparse/**',
'!exceljs/**',
'!amis-core/lib/utils/markdown.ts',
'!highlight.js/**',
'!argparse/**',
'!entities/**',
'!linkify-it/**',
'!mdurl/**',
'!uc.micro/**',
'!markdown-it/**',
'!markdown-it-html5-media/**'
],
'pkg/npm.css': ['node_modules/*/**.css', '!monaco-editor/**'],
// css 打包
'pkg/style.css': [
'*.scss',
'*.css',
'!scss/themes/*.scss',
// 要切换主题,不能打在一起。'/scss/*.scss',
'!/examples/style.scss',
'!monaco-editor/**',
'!scss/helper.scss',
'/examples/style.scss' // 让它在最下面
]
}),
postpackager: [
fis.plugin('loader', {
useInlineMap: false,
resourceType: 'mod'
}),
function (ret) {
const indexHtml = ret.src['/examples/index.html'];
const appJs = ret.src['/examples/components/App.tsx'];
const DocJs = ret.src['/examples/components/Doc.tsx'];
const DocNavCN = ret.src['/examples/components/DocNavCN.ts'];
const Components = ret.src['/examples/components/Components.tsx'];
const DocCSS = ret.src['/examples/components/CssDocs.tsx'];
const ExampleJs = ret.src['/examples/components/Example.jsx'];
const pages = [];
const source = [
appJs.getContent(),
DocJs.getContent(),
DocNavCN.getContent(),
Components.getContent(),
DocCSS.getContent(),
ExampleJs.getContent()
].join('\n');
source.replace(
/\bpath\b\s*\:\s*('|")(.*?)\1/g,
function (_, qutoa, path) {
if (path === '*') {
return;
}
pages.push(path.replace(/^\//, ''));
return _;
}
);
const contents = indexHtml.getContent();
pages.forEach(function (path) {
const file = fis.file(
fis.project.getProjectPath(),
'/examples/' + path + '.html'
);
file.setContent(contents);
ret.pkg[file.getId()] = file;
});
}
]
});
ghPages.match('*.{css,less,scss}', {
optimizer: [
function (contents) {
if (typeof contents === 'string') {
contents = contents.replace(/\/\*\!markdown[\s\S]*?\*\//g, '');
}
return contents;
},
fis.plugin('clean-css')
],
useHash: true
});
ghPages.match('::image', {
useHash: true
});
ghPages.match('*.{js,ts,tsx,jsx}', {
optimizer: fis.plugin('terser'),
useHash: true
});
ghPages.match('*.map', {
release: false,
url: 'null',
useHash: false
});
ghPages.match('{*.jsx,*.tsx,*.ts,/examples/**.js,}', {
moduleId: function (m, path) {
return fis.util.md5('amis' + path);
},
parser: [
// docsGennerator,
fis.plugin('typescript', {
sourceMap: false,
importHelpers: true,
esModuleInterop: true
}),
function (contents) {
return contents
.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 +
'}})()'
);
}
)
.replace(/\(\d+, (tslib_\d+\.__importStar)\)/g, '$1')
.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));})});`;
}
);
}
]
});
ghPages.match('*', {
domain: '/amis',
deploy: [
fis.plugin('skip-packed'),
fis.plugin('local-deliver', {
to: './gh-pages'
})
]
});
ghPages.match('{*.min.js,monaco-editor/min/**.js}', {
optimizer: null
});
ghPages.match('docs.json', {
domain: null
});
}