让示例可以跑起来

This commit is contained in:
liaoxuezhi 2022-06-01 21:35:49 +08:00
parent 7a83562589
commit dcfef5ddb6
27 changed files with 249 additions and 166 deletions

View File

@ -11,8 +11,8 @@ import {
Select, Select,
InputBox InputBox
} from 'amis'; } from 'amis';
import {eachTree, mapTree} from 'amis/lib/utils/helper'; import {eachTree, mapTree} from 'amis-core';
import 'amis/lib/locale/en-US'; import 'amis-ui/lib/locale/en-US';
import {withRouter} from 'react-router'; import {withRouter} from 'react-router';
import DocSearch from './DocSearch'; import DocSearch from './DocSearch';
import Doc from './Doc'; import Doc from './Doc';

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import {Switch} from 'react-router-dom'; import {Switch} from 'react-router-dom';
import {flattenTree, filterTree, mapTree} from 'amis/lib/utils/helper'; import {flattenTree, filterTree, mapTree} from 'amis-core';
import {navigations2route} from './App'; import {navigations2route} from './App';
import DocNavCN from './DocNavCN'; import DocNavCN from './DocNavCN';

View File

@ -7,7 +7,7 @@ import example from './EChartsEditor/Example';
import {lazyData} from './LazyData'; import {lazyData} from './LazyData';
import React from 'react'; import React from 'react';
import Spinner from 'amis/lib/components/Spinner'; import {Spinner} from 'amis-ui';
const LazyComponent = lazyData( const LazyComponent = lazyData(
async () => async () =>

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import Editor from 'amis/editor/Editor'; import {Editor} from 'amis-ui';
import Switch from 'amis/components/Switch'; import {Switch} from 'amis-ui';
import Button from 'amis/components/Button'; import {Button} from 'amis-ui';
import schema from './Form/Test'; import schema from './Form/Test';
import Portal from 'react-overlays/Portal'; import Portal from 'react-overlays/Portal';

View File

@ -117,9 +117,6 @@ import Tab1Schema from './Tabs/Tab1';
import Tab2Schema from './Tabs/Tab2'; import Tab2Schema from './Tabs/Tab2';
import Tab3Schema from './Tabs/Tab3'; import Tab3Schema from './Tabs/Tab3';
import TestComponent from './Test';
import {normalizeLink} from 'amis/utils/normalizeLink';
import {Switch} from 'react-router-dom'; import {Switch} from 'react-router-dom';
import {navigations2route} from './App'; import {navigations2route} from './App';

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {FormItem, Renderer} from 'amis'; import {FormItem, Renderer} from 'amis-core';
@FormItem({ @FormItem({
type: 'my-custom' type: 'my-custom'

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import TitleBar from 'amis/components/TitleBar'; import {TitleBar} from 'amis-ui';
import {render} from 'amis'; import {render} from 'amis';
const Schema = { const Schema = {

View File

@ -3,12 +3,9 @@ import React from 'react';
import {findDOMNode} from 'react-dom'; import {findDOMNode} from 'react-dom';
import {createRoot} from 'react-dom/client'; import {createRoot} from 'react-dom/client';
import {getTheme, render} from 'amis'; import {getTheme, render} from 'amis';
import axios from 'axios'; import {LazyComponent} from 'amis-core';
import TitleBar from 'amis/lib/components/TitleBar'; import {Overlay} from 'amis-ui';
import LazyComponent from 'amis/lib/components/LazyComponent'; import {PopOver} from 'amis-ui';
import Overlay from 'amis/lib/components/Overlay';
import PopOver from 'amis/lib/components/PopOver';
import NestedLinks from 'amis/lib/components/AsideNav';
import classnames from 'classnames'; import classnames from 'classnames';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import Play from './Play'; import Play from './Play';

View File

@ -1,15 +1,15 @@
import React from 'react'; import React from 'react';
import {toast, render, makeTranslator} from 'amis'; import {toast, render, makeTranslator} from 'amis';
import {normalizeLink} from 'amis/lib/utils/normalizeLink'; import {normalizeLink} from 'amis-core';
import {isMobile} from 'amis/lib/utils/helper'; import {isMobile} from 'amis-core';
import attachmentAdpator from 'amis/lib/utils/attachmentAdpator'; import {attachmentAdpator} from 'amis-core';
import {alert, confirm} from 'amis/lib/components/Alert'; import {alert, confirm} from 'amis-ui';
import axios from 'axios'; import axios from 'axios';
import JSON5 from 'json5'; import JSON5 from 'json5';
import CodeEditor from 'amis/lib/components/Editor'; import {Editor as CodeEditor} from 'amis-ui';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import {matchPath} from 'react-router-dom'; import {matchPath} from 'react-router-dom';
import Drawer from 'amis/lib/components/Drawer'; import {Drawer} from 'amis-ui';
const DEFAULT_CONTENT = `{ const DEFAULT_CONTENT = `{
"$schema": "/schemas/page.json#", "$schema": "/schemas/page.json#",

View File

@ -3,16 +3,14 @@ import {render, toast, Button, LazyComponent, Drawer} from 'amis';
import axios from 'axios'; import axios from 'axios';
import Portal from 'react-overlays/Portal'; import Portal from 'react-overlays/Portal';
import {toast} from 'amis'; import {toast} from 'amis';
import {normalizeLink} from 'amis/lib/utils/normalizeLink'; import {normalizeLink} from 'amis-core';
import {withRouter} from 'react-router'; import {withRouter} from 'react-router';
import {matchPath} from 'react-router-dom';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import {qsparse} from 'amis/lib/utils/helper'; import {qsparse} from 'amis-core';
function loadEditor() { function loadEditor() {
return new Promise(resolve => return new Promise(resolve =>
require(['amis/lib/components/Editor'], component => require(['amis-ui'], component => resolve(component.Editor))
resolve(component.default))
); );
} }

View File

@ -4,7 +4,7 @@ import {createRoot} from 'react-dom/client';
import axios from 'axios'; import axios from 'axios';
import {match} from 'path-to-regexp'; import {match} from 'path-to-regexp';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import {normalizeLink} from 'amis/lib/utils/normalizeLink'; import {normalizeLink} from 'amis-core';
import qs from 'qs'; import qs from 'qs';
import { import {
@ -17,11 +17,11 @@ import {
makeTranslator makeTranslator
} from 'amis'; } from 'amis';
import 'amis/lib/locale/en-US'; import 'amis-ui/lib/locale/en-US';
import 'history'; import 'history';
import attachmentAdpator from 'amis/lib/utils/attachmentAdpator'; import {attachmentAdpator} from 'amis-core';
import type {ToastLevel, ToastConf} from 'amis/lib/components/Toast'; import type {ToastLevel, ToastConf} from 'amis-ui/lib/components/Toast';
export function embed( export function embed(
container: string | HTMLElement, container: string | HTMLElement,

View File

@ -1,36 +1,31 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh"> <html lang="zh">
<head>
<meta charset="UTF-8" />
<title>amis - 低代码前端框架</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="image/x-icon" rel="shortcut icon" href="./static/favicon.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link rel="stylesheet" href="./static/iconfont.css" />
<link rel="stylesheet" href="@fortawesome/fontawesome-free/css/all.css" />
<link
rel="stylesheet"
href="@fortawesome/fontawesome-free/css/v4-shims.css"
/>
<link rel="stylesheet" href="prismjs/themes/prism.css" />
<!--DEPENDENCIES_INJECT_PLACEHOLDER-->
<link rel="stylesheet" href="./doc.css" />
<link rel="stylesheet" href="./style.scss" /> <head>
<!--STYLE_PLACEHOLDER--> <meta charset="UTF-8" />
<style> <title>amis - 低代码前端框架</title>
.app-wrapper, <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
.schema-wrapper { <link type="image/x-icon" rel="shortcut icon" href="./static/favicon.png" />
position: relative; <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
width: 100%; <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
height: 100%; <link rel="stylesheet" href="./static/iconfont.css" />
} <link rel="stylesheet" href="@fortawesome/fontawesome-free/css/all.css" />
</style> <link rel="stylesheet" href="@fortawesome/fontawesome-free/css/v4-shims.css" />
<script type="text/x-jsx"> <link rel="stylesheet" href="prismjs/themes/prism.css" />
<!--DEPENDENCIES_INJECT_PLACEHOLDER-->
<link rel="stylesheet" href="./doc.css" />
<link rel="stylesheet" href="./style.scss" />
<!--STYLE_PLACEHOLDER-->
<style>
.app-wrapper,
.schema-wrapper {
position: relative;
width: 100%;
height: 100%;
}
</style>
<script type="text/x-jsx">
// gitee 最近特别慢 // gitee 最近特别慢
if (location.hostname === 'baidu.gitee.io') { if (location.hostname === 'baidu.gitee.io') {
location.hostname = 'aisuda.bce.baidu.com'; location.hostname = 'aisuda.bce.baidu.com';
@ -46,75 +41,76 @@
document.write( document.write(
`<link rel="stylesheet" title="ang" ${ `<link rel="stylesheet" title="ang" ${
theme !== 'ang' ? 'disabled' : '' theme !== 'ang' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/ang.scss')}" />` } href="${__uri('amis-ui/lib/themes/ang.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="cxd" ${ `<link rel="stylesheet" title="cxd" ${
theme !== 'cxd' ? 'disabled' : '' theme !== 'cxd' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/cxd.scss')}" />` } href="${__uri('amis-ui/lib/themes/cxd.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="dark" ${ `<link rel="stylesheet" title="dark" ${
theme !== 'dark' ? 'disabled' : '' theme !== 'dark' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/dark.scss')}" />` } href="${__uri('amis-ui/lib/themes/dark.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="antd" ${ `<link rel="stylesheet" title="antd" ${
theme !== 'antd' ? 'disabled' : '' theme !== 'antd' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/antd.scss')}" />` } href="${__uri('amis-ui/lib/themes/antd.css')}" />`
); );
} else { } else {
document.write( document.write(
`<link rel="stylesheet" title="ang" ${ `<link rel="stylesheet" title="ang" ${
theme !== 'ang' ? 'disabled' : '' theme !== 'ang' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/ang-ie11.scss')}" />` } href="${__uri('amis-ui/lib/themes/ang-ie11.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="cxd" ${ `<link rel="stylesheet" title="cxd" ${
theme !== 'cxd' ? 'disabled' : '' theme !== 'cxd' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/cxd-ie11.scss')}" />` } href="${__uri('amis-ui/lib/themes/cxd-ie11.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="dark" ${ `<link rel="stylesheet" title="dark" ${
theme !== 'dark' ? 'disabled' : '' theme !== 'dark' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/dark-ie11.scss')}" />` } href="${__uri('amis-ui/lib/themes/dark-ie11.css')}" />`
); );
document.write( document.write(
`<link rel="stylesheet" title="antd" ${ `<link rel="stylesheet" title="antd" ${
theme !== 'antd' ? 'disabled' : '' theme !== 'antd' ? 'disabled' : ''
} href="${__uri('amis/scss/themes/antd-ie11.scss')}" />` } href="${__uri('amis-ui/lib/themes/antd-ie11.css')}" />`
); );
} }
</script> </script>
<!--ignore--> <!--ignore-->
<link rel="stylesheet" href="amis/scss/helper.scss" /> <link rel="stylesheet" href="amis-ui/lib/helper.css" />
<!--ignore--> <!--ignore-->
</head> </head>
<body> <body>
<div id="root" class="app-wrapper"></div> <div id="root" class="app-wrapper"></div>
<script src="./mod.js"></script> <script src="./mod.js"></script>
<script type="text/javascript"> <script type="text/javascript">
if (location.hostname !== 'localhost') { if (location.hostname !== 'localhost') {
var _hmt = _hmt || []; var _hmt = _hmt || [];
// 百度统计 // 百度统计
(function () { (function () {
var hm = document.createElement('script'); var hm = document.createElement('script');
hm.src = hm.src =
'https://hm.baidu.com/hm.js?286766a21abb57abefedbd5257a26dc8'; 'https://hm.baidu.com/hm.js?286766a21abb57abefedbd5257a26dc8';
var s = document.getElementsByTagName('script')[0]; var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s); s.parentNode.insertBefore(hm, s);
})(); })();
} }
window.enableAMISDebug = true; window.enableAMISDebug = true;
/* @require ./index.jsx 标记为同步依赖,提前加载 */ /* @require ./index.jsx 标记为同步依赖,提前加载 */
amis.require(['./index.jsx'], function (app) { amis.require(['./index.jsx'], function (app) {
var initialState = {}; var initialState = {};
app.bootstrap(document.getElementById('root'), initialState); app.bootstrap(document.getElementById('root'), initialState);
}); });
</script> </script>
</body> </body>
</html>
</html>

View File

@ -9,7 +9,7 @@ import {createRoot} from 'react-dom/client';
import axios from 'axios'; import axios from 'axios';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import {toast} from 'amis'; import {toast} from 'amis';
import 'amis/lib/locale/en-US'; import 'amis-ui/lib/locale/en-US';
import {render as renderAmis} from 'amis'; import {render as renderAmis} from 'amis';

View File

@ -1,6 +1,6 @@
@import 'node_modules/amis/scss/mixins'; @import 'node_modules/amis-ui/scss/mixins';
@import 'node_modules/amis/scss/functions'; @import 'node_modules/amis-ui/scss/functions';
@import 'node_modules/amis/scss/variables'; @import 'node_modules/amis-ui/scss/variables';
body { body {
background-color: #fff !important; background-color: #fff !important;

View File

@ -9,5 +9,21 @@
"stop": "fis3 server stop", "stop": "fis3 server stop",
"dev": "fis3 release -cwd ./public", "dev": "fis3 release -cwd ./public",
"deploy-gh-page": "sh ./deploy-gh-pages.sh" "deploy-gh-page": "sh ./deploy-gh-pages.sh"
},
"devDependencies": {
"fis-optimizer-terser": "^1.0.1",
"fis-parser-sass": "^1.1.1",
"fis-parser-svgr": "^1.0.0",
"fis3": "^3.4.41",
"fis3-deploy-skip-packed": "0.0.5",
"fis3-hook-commonjs": "^0.1.31",
"fis3-hook-node_modules": "^2.3.1",
"fis3-hook-relative": "^2.0.3",
"fis3-packager-deps-pack": "^0.1.2",
"fis3-parser-typescript": "^1.4.0",
"fis3-postpackager-loader": "^2.1.12",
"fis3-prepackager-stand-alone-pack": "^1.0.0",
"fis3-preprocessor-js-require-css": "^0.1.3",
"fis3-preprocessor-js-require-file": "^0.1.3"
} }
} }

View File

@ -55,7 +55,9 @@
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"react-json-view": "1.21.3", "react-json-view": "1.21.3",
"react-visibility-sensor": "5.1.1", "react-visibility-sensor": "5.1.1",
"tslib": "^2.3.1" "tslib": "^2.3.1",
"markdown-it": "^12.0.6",
"markdown-it-html5-media": "^0.7.1"
}, },
"jest": { "jest": {
"testEnvironment": "jsdom", "testEnvironment": "jsdom",

View File

@ -146,6 +146,7 @@ export function renderChild(
return ( return (
<SchemaRenderer <SchemaRenderer
render={renderChild as any}
{...props} {...props}
schema={schema} schema={schema}
propKey={schema.key} propKey={schema.key}

View File

@ -71,10 +71,6 @@ import {
import {Schema} from './types'; import {Schema} from './types';
import ScopedRootRenderer, {RootRenderProps} from './Root'; import ScopedRootRenderer, {RootRenderProps} from './Root';
import {envOverwrite} from './envOverwrite'; import {envOverwrite} from './envOverwrite';
import {wrapFetcher} from './utils/api';
import {autobind, promisify} from './utils/helper';
import {enableDebug} from './utils/debug';
import {replaceText} from './utils/replaceText';
import {EnvContext, RendererEnv} from './env'; import {EnvContext, RendererEnv} from './env';
import React from 'react'; import React from 'react';
import { import {
@ -90,6 +86,7 @@ import {
} from 'amis-formula'; } from 'amis-formula';
import LazyComponent from './components/LazyComponent'; import LazyComponent from './components/LazyComponent';
import {FormHorizontal, FormRenderer} from './renderers/Form'; import {FormHorizontal, FormRenderer} from './renderers/Form';
import {enableDebug, promisify, replaceText, wrapFetcher} from './utils/index';
export { export {
clearStoresCache, clearStoresCache,
@ -135,7 +132,6 @@ export {
localeable, localeable,
LocaleProps, LocaleProps,
TranslateFn, TranslateFn,
autobind,
ClassNamesFn, ClassNamesFn,
// amis-formula 相关 // amis-formula 相关
parse, parse,

View File

@ -36,7 +36,9 @@ const themes: {
[propName: string]: ThemeConfig; [propName: string]: ThemeConfig;
} = { } = {
default: {}, default: {},
cxd: {} cxd: {
classPrefix: 'cxd-'
}
}; };
export function theme(name: string, config: Partial<ThemeConfig>) { export function theme(name: string, config: Partial<ThemeConfig>) {

View File

@ -5,7 +5,7 @@
* @returns * @returns
*/ */
export default function attachmentAdpator(response: any, __: Function) { export function attachmentAdpator(response: any, __: Function) {
if (response && response.headers && response.headers['content-disposition']) { if (response && response.headers && response.headers['content-disposition']) {
const disposition = response.headers['content-disposition']; const disposition = response.headers['content-disposition'];
let filename = ''; let filename = '';
@ -88,3 +88,5 @@ export default function attachmentAdpator(response: any, __: Function) {
return response; return response;
} }
export default attachmentAdpator;

View File

@ -162,7 +162,7 @@ export function findIndex(
return -1; return -1;
} }
export function hasOwnProperty( export function hasOwnPropertyInPath(
data: {[propName: string]: any}, data: {[propName: string]: any},
key: string key: string
): boolean { ): boolean {

View File

@ -1,32 +1,54 @@
export * from './helper';
export * from './resize-sensor';
export * from './api'; export * from './api';
export * from './tpl'; export * from './attachmentAdpator';
export * from './tpl-builtin'; export * from './autobind';
export * from './DataScope'; export * from './ColorScale';
export * from './DataSchema';
export * from './normalizeOptions';
export * from './validations';
export * from './icon';
export * from './style';
export * from './RootClose';
export * from './dom';
export * from './columnsSplit'; export * from './columnsSplit';
export * from './highlight'; export * from './dataMapping';
export * from './DataSchema';
export * from './DataScope';
export * from './date';
export * from './debug';
export * from './dom';
export * from './errors';
export * from './escapeHtml';
export * from './filter-schema'; export * from './filter-schema';
export * from './SimpleMap'; export * from './filter';
export * from './optionValueCompare'; export * from './formatDuration';
export * from './formula';
export * from './getVariable';
export * from './grammar';
export * from './handleAction';
export * from './helper';
export * from './highlight';
export * from './icon';
export * from './image'; export * from './image';
export * from './isPureVariable';
export * from './json-schema-2-amis-schema';
export * from './keyToPath';
export * from './makeSorter';
export * from './markdown';
export * from './normalizeLink';
export * from './normalizeOptions';
export * from './object';
export * from './offset'; export * from './offset';
export * from './offsetParent'; export * from './offsetParent';
export * from './ColorScale'; export * from './optionValueCompare';
export * from './position';
export * from './prettyBytes';
export * from './renderer-event'; export * from './renderer-event';
export * from './handleAction'; export * from './replaceText';
export * from './resize-sensor';
export * from './resolveVariable';
export * from './resolveVariableAndFilter';
export * from './RootClose';
export * from './scrollPosition'; export * from './scrollPosition';
export * from './formula'; export * from './SimpleMap';
export * from './grammar'; export * from './string2regExp';
export * from './style';
import './debug'; export * from './tokenize';
export * from './tpl-builtin';
export * from './tpl';
export * from './validations';
import animation from './Animation'; import animation from './Animation';
import markdownRender from './markdown'; import markdownRender from './markdown';

View File

@ -6,13 +6,15 @@ import markdownIt from 'markdown-it';
// @ts-ignore // @ts-ignore
import {html5Media} from 'markdown-it-html5-media'; import {html5Media} from 'markdown-it-html5-media';
const markdown = markdownIt(); const doMarkdown = markdownIt();
markdown.use(html5Media); doMarkdown.use(html5Media);
export default function (content: string, options?: markdownIt.Options) { export function markdown(content: string, options?: markdownIt.Options) {
if (options) { if (options) {
markdown.set(options); doMarkdown.set(options);
} }
return markdown.render(content); return doMarkdown.render(content);
} }
export default markdown;

View File

@ -14,10 +14,7 @@ const nodeName = (node: Element) =>
* @param node the element * @param node the element
* @param offsetParent the offset parent * @param offsetParent the offset parent
*/ */
export default function position( export function position(node: HTMLElement, offsetParent?: HTMLElement) {
node: HTMLElement,
offsetParent?: HTMLElement
) {
let parentOffset = {top: 0, left: 0}; let parentOffset = {top: 0, left: 0};
let offset; let offset;
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
@ -53,3 +50,5 @@ export default function position(
left: offset.left - parentOffset.left - (parseInt(marginLeft, 10) || 0) left: offset.left - parentOffset.left - (parseInt(marginLeft, 10) || 0)
}; };
} }
export default position;

View File

@ -59,17 +59,23 @@
"@rollup/plugin-typescript": "^8.3.2", "@rollup/plugin-typescript": "^8.3.2",
"@svgr/rollup": "^6.2.1", "@svgr/rollup": "^6.2.1",
"@testing-library/jest-dom": "^5.16.4", "@testing-library/jest-dom": "^5.16.4",
"@types/babel__core": "^7.1.19",
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11", "@types/react-dom": "^17.0.11",
"autoprefixer": "^10.4.7",
"jest": "^27.2.1", "jest": "^27.2.1",
"moment-timezone": "^0.5.34", "moment-timezone": "^0.5.34",
"postcss-import": "^14.1.0",
"react": "^18.0.0", "react": "^18.0.0",
"react-dom": "^18.0.0", "react-dom": "^18.0.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.73.0", "rollup": "^2.73.0",
"rollup-plugin-auto-external": "^2.0.0", "rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-license": "^2.7.0", "rollup-plugin-license": "^2.7.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-scss": "^3.0.0",
"sass": "^1.52.1",
"typescript": "^4.6.4" "typescript": "^4.6.4"
} }
} }

View File

@ -5,6 +5,11 @@ import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
import license from 'rollup-plugin-license'; import license from 'rollup-plugin-license';
import autoExternal from 'rollup-plugin-auto-external'; import autoExternal from 'rollup-plugin-auto-external';
import sass from 'sass';
import postcss from 'rollup-plugin-postcss';
import postcssImport from 'postcss-import';
import autoprefixer from 'autoprefixer';
import { import {
name, name,
version, version,
@ -41,7 +46,14 @@ const input = [
export default [ export default [
{ {
input, input: input.concat([
'./scss/themes/antd.scss',
'./scss/themes/ang.scss',
'./scss/themes/cxd.scss',
'./scss/themes/dark.scss',
'./scss/themes/default.scss',
'./scss/helper.scss'
]),
output: [ output: [
{ {
@ -55,24 +67,42 @@ export default [
], ],
external, external,
plugins: getPlugins('cjs') plugins: getPlugins('cjs')
}, .concat(
['antd', 'ang', 'cxd', 'dark', 'default'].map(theme =>
{ postcss({
input, include: `**/${theme}.scss`,
// process: processSass,
output: [ extract: path.resolve(`lib/themes/${theme}.css`),
{ plugins: [postcssImport(), autoprefixer()]
...settings, })
dir: path.dirname(module), )
format: 'esm', )
exports: 'named', .concat(
preserveModulesRoot: './src', postcss({
preserveModules: true // Keep directory structure and files include: `**/helper.scss`,
} // process: processSass,
], extract: path.resolve(`lib/helper.css`),
external, plugins: [postcssImport(), autoprefixer()]
plugins: getPlugins('esm') })
)
} }
// {
// input,
// output: [
// {
// ...settings,
// dir: path.dirname(module),
// format: 'esm',
// exports: 'named',
// preserveModulesRoot: './src',
// preserveModules: true // Keep directory structure and files
// }
// ],
// external,
// plugins: getPlugins('esm')
// }
]; ];
function transpileDynamicImportForCJS(options) { function transpileDynamicImportForCJS(options) {
@ -135,3 +165,20 @@ function getPlugins(format = 'esm') {
}) })
]; ];
} }
function processSass(context, payload) {
return new Promise((resolve, reject) => {
sass.render(
{
file: context
},
function (err, result) {
if (!err) {
resolve(result);
} else {
reject(err);
}
}
);
});
}

View File

@ -1,8 +1,8 @@
@import url('../node_modules/codemirror/lib/codemirror.css?__inline'); @import url('codemirror/lib/codemirror.css');
@import url('../node_modules/froala-editor/css/froala_style.min.css?__inline'); @import url('froala-editor/css/froala_style.min.css');
@import url('../node_modules/froala-editor/css/froala_editor.pkgd.min.css?__inline'); @import url('froala-editor/css/froala_editor.pkgd.min.css');
@import url('../node_modules/tinymce/skins/ui/oxide/skin.css?__inline'); @import url('tinymce/skins/ui/oxide/skin.css');
@import url('../node_modules/video-react/dist/video-react.css?__inline'); @import url('video-react/dist/video-react.css');
@import url('../node_modules/cropperjs/dist/cropper.css?__inline'); @import url('cropperjs/dist/cropper.css');
@import './components/react-datetime'; @import './components/react-datetime';