Commit cab6ba4a authored by 田功镭's avatar 田功镭

*)add mf

parent d9d71884
*.iml *.iml
node_modules node_modules
lib lib
dist
*_dist
...@@ -23,6 +23,7 @@ src ...@@ -23,6 +23,7 @@ src
.project .project
.stylelintignore .stylelintignore
.stylelintrc.json .stylelintrc.json
.umdrc.js
/amos.config.js /amos.config.js
*.bat *.bat
*.html *.html
......
const { commonExternals } = require('amos-build/lib/tools/pluginConfig');
const umdConfig = commonExternals([
'react', 'react-dom', 'amos-react-router', 'prop-types', 'amos-antd', 'amos-framework', 'xgplayer', 'xgplayer-flv', 'xgplayer-hls', 'xgplayer-hls.js','amos-designer',
// studio asp remote 需要
'base-r3d', 'amos-gojs'
]);
module.exports = {
// dir 和 list 用于从 pkg 中拷贝 mf 包
dir: 'umd_lib',
list: [
...umdConfig.list,
// codemirror、ace
{ pkg: 'amos-code-actuator', umd: 'dist' },
// tinymce quill
{ pkg: 'amos-richtext', umd: 'umd' },
// echarts all
{ pkg: 'amos-viz', umd: 'umd' }
],
externals: {
...umdConfig.externals,
'amos-code-actuator/lib/codemirror/umd': 'ActuatorCM',
// ace editor
'amos-code-actuator/lib/ace/umd': 'ActuatorACE',
'amos-viz/lib/echarts/umd': 'VizEcharts',
// rich text
'amos-richtext/lib/quill/umd': 'RichTextQuill',
'amos-richtext/lib/tinymce/umd': 'RichTextMCE'
},
scripts: {
// 注意,数组中,靠前的后加载
head: [
...umdConfig.scripts.head
],
body: [
...umdConfig.scripts.body,
"amos-code-actuator/codemirror.umd.js",
"amos-code-actuator/ace.umd.js",
"amos-viz/viz-echarts.umd.js",
"amos-richtext/tinymce.umd.js",
"amos-richtext/quill.umd.js",
]
},
// link 样式可以, 均放在 head
links: [
...umdConfig.links
]
};
console.log('did not use this file!');
export { default as plugins } from './../src/index';
export * from './../src/index';
{ {
"name": "amos-iot-access", "name": "amos-iot-access",
"version": "1.0.4", "version": "1.1.0",
"private": false, "private": false,
"author": "ilex.h", "author": "ilex.h",
"main": "./lib/index.js",
"scripts": { "scripts": {
"clean": "rimraf dist released", "clean": "rimraf dist released",
"build:pro": "set NODE_ENV=production && npm run clean && webpack", "build:pro": "set NODE_ENV=production && npm run clean && webpack",
"build:dev": "set NODE_ENV=development && npm run clean && webpack", "build:dev": "set NODE_ENV=development && npm run clean && webpack",
"watch": "webpack -w", "watch": "webpack -w",
"server": "nodemon server/index.js --watch server", "server": "nodemon server/index.js --watch server",
"build": "set NODE_ENV=production && npm run clean && webpack",
"themes": "amos-run themes", "themes": "amos-run themes",
"themes-watch": "amos-run themes-watch", "themes-watch": "amos-run themes-watch",
"start": "set NODE_ENV=development && webpack-dev-server", "start": "set NODE_ENV=development && webpack-dev-server",
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
"zip": "amos-run released2zip", "zip": "amos-run released2zip",
"pub:dev": "npm run compile:dev && amos-run dllreleased", "pub:dev": "npm run compile:dev && amos-run dllreleased",
"pub:build": "npm run build:pro && amos-run dllreleased", "pub:build": "npm run build:pro && amos-run dllreleased",
"pub": "set NODE_ENV=production && npm run clean && ray-build react && ray-build stylescss && npm publish", "build": "ray-build react && ray-build stylescss",
"mf": "rimraf amosiot_dist & set NODE_ENV=production && webpack --config webpack.config.mf.js",
"pub": "npm run build && npm run mf && npm publish",
"precommit": "lint-staged" "precommit": "lint-staged"
}, },
"lint-staged": { "lint-staged": {
......
...@@ -24,6 +24,49 @@ package.json ...@@ -24,6 +24,49 @@ package.json
} }
``` ```
```js
// 采用 npm 包模块的方式引入
import iotPluginsRoutes, { initPluginsConfig as iotInitPluginsConfig } from 'amos-iot-access';
// 采用 mf 的方式引入
// import { plugins as iotPluginsRoutes, initPluginsConfig as iotInitPluginsConfig } from 'amosiot/access';
const plugin = {
...
...iotPluginsRoutes,
...
};
iotInitPluginsConfig({
staticHeader: {
appKey: 'AMOS_STUDIO',
product: 'AMOS_STUDIO_WEB'
}
});
```
> 注意,采用 mf 的方式引入 idx 模块时,需要在 mf remotes 中配置如下信息
- `.mfrc.js` 配置文件
```js
module.exports = {
list: [
...
{ pkg: 'amos-iot-access', mf: 'amosiot_dist' },
...
],
...
remotes: {
...
amosiot: "amosiot@[window.__mf_prefix_url__]/amosiot_dist/remoteEntry.js",
...
}
...
};
```
### changelog ### changelog
* v1.0.4(20220208) modify amos-viz umd supported - v1.0.4(20220208) modify amos-viz umd supported
- v1.1.0(20220208) add mf supported
/**
* webpack 打包配置文件
* @author ilex
*/
const MFConfig = require('amos-build/lib/MFConfig');
const { getReactMf, getRCConfigInfo } = require('amos-build/lib/tools/pluginConfig');
const resolveCwd = require('amos-build/lib/tools/resolveCwd');
const deps = require('./package.json').dependencies;
const umdRc = getRCConfigInfo('umd', '.');
// ------------------------------------
// 入口点
// ------------------------------------
const entry = {
app: './mf/entry.js'
};
const mfOption = {
name: 'amosiot',
library: { type: 'var', name: 'amosiot' },
filename: 'remoteEntry.js',
exposes: {
'./access': './mf/index.js'
},
shared: {
...getReactMf(deps.react, deps['react-dom'])
}
};
const config = {
tpl: './tpl.html',
toFile: 'index.html',
port: 3919,
entry,
outputPath: resolveCwd('amosiot_dist'),
mfConfig: mfOption,
lint: false,
sourceMap: false
};
const defaultConfig = MFConfig(config);
defaultConfig.name = 'amos-iot-access';
// 由于 iot remote 存放的路径不确定,此处禁止重新赋值
// defaultConfig.output.publicPath = '';
// 设置 外部脚本配置
defaultConfig.externals = umdRc.externals;
module.exports = defaultConfig;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment