neo-cmp-cli 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +3 -3
  2. package/package.json +3 -2
  3. package/src/module/index.js +2 -2
  4. package/src/module/main.js +12 -0
  5. package/src/module/neoInit.js +7 -7
  6. package/src/module/neoInitByCopy.js +7 -7
  7. package/src/oss/publish2oss.js +8 -2
  8. package/src/template/{react-custom-widget-template → react-custom-cmp-template}/README.md +3 -1
  9. package/src/template/{react-custom-widget-template → react-custom-cmp-template}/package.json +4 -4
  10. package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/README.md +3 -2
  11. package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/neo.config.js +24 -1
  12. package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/package.json +5 -5
  13. package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/info-card/index.tsx +3 -1
  14. package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/README.md +3 -1
  15. package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/package.json +4 -4
  16. package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/widgets/info-card/index.vue +16 -16
  17. package/src/utils/webpack.mf.js +59 -0
  18. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/.editorconfig +0 -0
  19. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/.prettierrc.js +0 -0
  20. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/commitlint.config.js +0 -0
  21. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/neo.config.js +0 -0
  22. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/public/css/base.css +0 -0
  23. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/public/scripts/app/bluebird.js +0 -0
  24. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/public/template.html +0 -0
  25. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/assets/css/common.scss +0 -0
  26. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/assets/css/mixin.scss +0 -0
  27. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/components/info-card/index.jsx +0 -0
  28. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/components/info-card/model.js +0 -0
  29. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/components/info-card/register.js +0 -0
  30. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/components/info-card/style.scss +0 -0
  31. /package/src/template/{react-custom-widget-template → react-custom-cmp-template}/src/preview.js +0 -0
  32. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/.editorconfig +0 -0
  33. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/.prettierrc.js +0 -0
  34. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/commitlint.config.js +0 -0
  35. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/public/css/base.css +0 -0
  36. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/public/scripts/app/bluebird.js +0 -0
  37. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/public/template.html +0 -0
  38. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/assets/css/common.scss +0 -0
  39. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/assets/css/mixin.scss +0 -0
  40. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/info-card/model.ts +0 -0
  41. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/info-card/register.ts +0 -0
  42. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/info-card/style.scss +0 -0
  43. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/list-widget/README.md +0 -0
  44. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/list-widget/index.tsx +0 -0
  45. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/list-widget/model.ts +0 -0
  46. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/list-widget/register.ts +0 -0
  47. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/components/list-widget/style.scss +0 -0
  48. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/src/preview.tsx +0 -0
  49. /package/src/template/{react-ts-custom-widget-template → react-ts-custom-cmp-template}/tsconfig.json +0 -0
  50. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/.editorconfig +0 -0
  51. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/.prettierrc.js +0 -0
  52. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/commitlint.config.js +0 -0
  53. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/neo.config.js +0 -0
  54. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/public/css/base.css +0 -0
  55. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/public/scripts/app/bluebird.js +0 -0
  56. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/public/template.html +0 -0
  57. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/assets/css/common.scss +0 -0
  58. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/assets/css/mixin.scss +0 -0
  59. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/preview.js +0 -0
  60. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/widgets/info-card/model.js +0 -0
  61. /package/src/template/{vue2-neo-custom-widget → vue2-custom-cmp-template}/src/widgets/info-card/register.js +0 -0
package/README.md CHANGED
@@ -11,9 +11,9 @@ neo-cmp-cli 是 Neo 自定义组件开发工具,基于 [AKFun](https://github.
11
11
  - **一键发布**: 内置发布到 OSS 的能力,支持自定义对象存储配置。
12
12
 
13
13
  ### 模板类型(neo init 可选)
14
- - **React 模板**: [react-custom-widget-template](https://github.com/wibetter/react-custom-widget-template)
15
- - **React + TS 模板**: [react-ts-custom-widget-template](https://github.com/wibetter/react-ts-custom-widget-template)
16
- - **Vue2 模板**: [vue2-neo-custom-widget](https://github.com/wibetter/vue2-neo-custom-widget)
14
+ - **React 模板**: [react-custom-cmp-template](https://github.com/wibetter/react-custom-cmp-template)
15
+ - **React + TS 模板**: [react-ts-custom-cmp-template](https://github.com/wibetter/react-ts-custom-cmp-template)
16
+ - **Vue2 模板**: [vue2-custom-cmp-template](https://github.com/wibetter/vue2-custom-cmp-template)
17
17
 
18
18
  ## 快速开始
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -50,7 +50,8 @@
50
50
  "ora": "^4.0.4",
51
51
  "webpack-sources": "^3.2.3",
52
52
  "yargs": "^12.0.2",
53
- "lodash": "^4.17.21"
53
+ "lodash": "^4.17.21",
54
+ "external-remotes-plugin": "^1.5.0"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@commitlint/cli": "^8.3.5",
@@ -99,8 +99,8 @@ yargs
99
99
  questions.push({
100
100
  name: 'name',
101
101
  type: 'input',
102
- message: '请设置自定义组件项目名称(默认 neoCustomWidget):',
103
- default: 'neoCustomWidget'
102
+ message: '请设置自定义组件项目名称(默认 neoCustomCmp):',
103
+ default: 'neoCustomCmp'
104
104
  });
105
105
  }
106
106
  inquirer.prompt(questions).then((ans) => {
@@ -8,6 +8,7 @@ const { consoleTag } = require('../utils/neoParams');
8
8
  const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
9
9
  const publish2oss = require('../oss/publish2oss');
10
10
  const getEntries = require('../utils/getEntries');
11
+ const { MFPlugins } = require('../utils/webpack.mf');
11
12
 
12
13
  const getValue = (originValue, defaultValue) => {
13
14
  return originValue !== undefined ? originValue : defaultValue;
@@ -57,6 +58,9 @@ module.exports = {
57
58
  }
58
59
  }
59
60
 
61
+ // 添加模块联邦插件
62
+ curConfig.webpack.plugins.push(...MFPlugins);
63
+
60
64
  akfun.dev(curConfig, consoleTag);
61
65
  },
62
66
  build: () => akfun.build('build', curConfig, consoleTag), // 构建脚本:生产环境
@@ -75,6 +79,11 @@ module.exports = {
75
79
  }
76
80
  }
77
81
 
82
+ if (curConfig.build2lib.enableMF) {
83
+ // 添加模块联邦插件
84
+ curConfig.webpack.plugins.push(...MFPlugins);
85
+ }
86
+
78
87
  akfun.build('lib', curConfig, consoleTag);
79
88
  }, // 构建脚本:生产环境
80
89
  publish2oss: () => {
@@ -96,6 +105,9 @@ module.exports = {
96
105
  }
97
106
  }
98
107
 
108
+ // 添加模块联邦插件
109
+ curConfig.webpack.plugins.push(...MFPlugins);
110
+
99
111
  akfun.build('lib', curConfig, consoleTag, () => {
100
112
  // 构建完成后,执行 publish2oss
101
113
  publish2oss(
@@ -4,16 +4,16 @@ const { replaceInPackage } = require('../utils/replaceInPackage');
4
4
 
5
5
  const templateList = {
6
6
  react: {
7
- projectName: 'react-custom-widget-template',
8
- url: 'git@github.com:wibetter/react-custom-widget-template.git'
7
+ projectName: 'react-custom-cmp-template',
8
+ url: 'git@github.com:wibetter/react-custom-cmp-template.git'
9
9
  },
10
10
  'react-ts': {
11
- projectName: 'react-ts-custom-widget-template',
12
- url: 'git@github.com:wibetter/react-ts-custom-widget-template.git'
11
+ projectName: 'react-ts-custom-cmp-template',
12
+ url: 'git@github.com:wibetter/react-ts-custom-cmp-template.git'
13
13
  },
14
14
  vue2: {
15
- projectName: 'vue2-neo-custom-widget',
16
- url: 'git@github.com:wibetter/vue2-neo-custom-widget.git'
15
+ projectName: 'vue2-custom-cmp-template',
16
+ url: 'git@github.com:wibetter/vue2-custom-cmp-template.git'
17
17
  }
18
18
  /*
19
19
  'vue3': {
@@ -26,7 +26,7 @@ const templateList = {
26
26
  const neoInit = function (type, projectName) {
27
27
  const currentTemplate = templateList[type || 'react'];
28
28
  const currentTemplateUrl = currentTemplate.url;
29
- const finalProjectName = projectName || 'neoCustomWidget';
29
+ const finalProjectName = projectName || 'neoCustomCmp';
30
30
 
31
31
  gitClone(
32
32
  currentTemplateUrl,
@@ -5,23 +5,23 @@ const { replaceInPackage } = require('../utils/replaceInPackage');
5
5
 
6
6
  const templateList = {
7
7
  react: {
8
- projectName: 'react-custom-widget-template',
9
- dir: path.resolve(__dirname, '../template/react-custom-widget-template')
8
+ projectName: 'react-custom-cmp-template',
9
+ dir: path.resolve(__dirname, '../template/react-custom-cmp-template')
10
10
  },
11
11
  'react-ts': {
12
- projectName: 'react-ts-custom-widget-template',
13
- dir: path.resolve(__dirname, '../template/react-ts-custom-widget-template')
12
+ projectName: 'react-ts-custom-cmp-template',
13
+ dir: path.resolve(__dirname, '../template/react-ts-custom-cmp-template')
14
14
  },
15
15
  vue2: {
16
- projectName: 'vue2-neo-custom-widget',
17
- dir: path.resolve(__dirname, '../template/vue2-neo-custom-widget')
16
+ projectName: 'vue2-custom-cmp-template',
17
+ dir: path.resolve(__dirname, '../template/vue2-custom-cmp-template')
18
18
  }
19
19
  };
20
20
 
21
21
  const neoInitByCopy = function (type, projectName) {
22
22
  const currentTemplate = templateList[type || 'react'];
23
23
  const currentTemplateDir = currentTemplate.dir;
24
- const finalProjectName = projectName || 'neoCustomWidget';
24
+ const finalProjectName = projectName || 'neoCustomCmp';
25
25
  const finalProjectPath = path.resolve(process.cwd(), finalProjectName);
26
26
 
27
27
  fs.copy(currentTemplateDir, finalProjectPath)
@@ -107,14 +107,20 @@ const getBosClient = (ossType, ossConfig) => {
107
107
  return new baiduBOS(
108
108
  ossConfig.endpoint,
109
109
  ossConfig.bucket,
110
- ossConfig.AccessKeyId || ossConfig.AccessKeyID || ossConfig.accessKeyId || ossConfig.accessKeyID,
110
+ ossConfig.AccessKeyId ||
111
+ ossConfig.AccessKeyID ||
112
+ ossConfig.accessKeyId ||
113
+ ossConfig.accessKeyID,
111
114
  ossConfig.AccessKeySecret
112
115
  );
113
116
  } else if (ossType === 'ali') {
114
117
  return new aliBOS(
115
118
  ossConfig.endpoint,
116
119
  ossConfig.bucket,
117
- ossConfig.AccessKeyId || ossConfig.AccessKeyID || ossConfig.accessKeyId || ossConfig.accessKeyID,
120
+ ossConfig.AccessKeyId ||
121
+ ossConfig.AccessKeyID ||
122
+ ossConfig.accessKeyId ||
123
+ ossConfig.accessKeyID,
118
124
  ossConfig.AccessKeySecret
119
125
  );
120
126
  }
@@ -12,7 +12,9 @@
12
12
  - 存放在 src/components 目录下的自定义组件,默认 index 为自定义组件源码入口文件,register.[tj]s 为注册 Neo 组件的脚本文件,model.[tj]s 为自定义组件的描述文件(和页面设计器对接需要);
13
13
  - 当 neo.config.js 中的 entry 为空或者不存在时,cli 将根据 src/components 目录下的自定义组件结构生成对应的 entry 配置(可在命令控制台查看生成的 entry 配置);
14
14
  - 自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md);
15
- - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中;
15
+ - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中,避免自定义组件样式相互干扰;
16
+ - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置;
17
+ - 请使用 react 16版本。
16
18
 
17
19
  ### 自定义组件注册器使用说明
18
20
  - [neo-register 使用说明](https://www.npmjs.com/package/neo-register?activeTab=readme)
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "react-custom-widget-template",
2
+ "name": "react-custom-cmp-template",
3
3
  "version": "1.0.0",
4
4
  "description": "neo自定义组件模板(react技术栈)",
5
5
  "keywords": [
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://git@github.com:wibetter/react-custom-widget-template.git"
34
+ "url": "https://git@github.com:wibetter/react-custom-cmp-template.git"
35
35
  },
36
36
  "bugs": {
37
- "url": "https://github.com/wibetter/react-custom-widget-template/issues"
37
+ "url": "https://github.com/wibetter/react-custom-cmp-template/issues"
38
38
  },
39
39
  "dependencies": {
40
40
  "neo-register": "^1.0.0",
@@ -44,7 +44,7 @@
44
44
  "devDependencies": {
45
45
  "@commitlint/cli": "^8.3.5",
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
- "neo-cmp-cli": "^1.0.2",
47
+ "neo-cmp-cli": "^1.0.3",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5"
@@ -12,8 +12,9 @@
12
12
  - 存放在 src/components 目录下的自定义组件,默认 index 为自定义组件源码入口文件,register.[tj]s 为注册 Neo 组件的脚本文件,model.[tj]s 为自定义组件的描述文件(和页面设计器对接需要);
13
13
  - 当 neo.config.js 中的 entry 为空或者不存在时,cli 将根据 src/components 目录下的自定义组件结构生成对应的 entry 配置(可在命令控制台查看生成的 entry 配置);
14
14
  - 自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md);
15
- - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中;
16
- - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置。
15
+ - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中,避免自定义组件样式相互干扰;
16
+ - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置;
17
+ - 请使用 react 16版本。
17
18
 
18
19
  ### 自定义组件注册器使用说明
19
20
  - [neo-register 使用说明](https://www.npmjs.com/package/neo-register?activeTab=readme)
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
  const path = require('path');
3
+ const { ModuleFederationPlugin } = require('webpack').container;
4
+ const curDependencies = require('./package.json').dependencies;
3
5
 
4
6
  // 统一路径解析
5
7
  function resolve(dir) {
@@ -34,7 +36,28 @@ module.exports = {
34
36
  allowList: [], // ignoreNodeModules为true时生效
35
37
  projectDir: ['src'],
36
38
  // template: resolve('./public/template.html'), // 自定义html模板
37
- // plugins: []
39
+ plugins: [
40
+ new ModuleFederationPlugin({
41
+ name: 'NeoCLIDeps',
42
+ shared: [
43
+ {
44
+ react: {
45
+ requiredVersion: curDependencies.react,
46
+ singleton: true,
47
+ eager: true,
48
+ },
49
+ 'react-dom': {
50
+ requiredVersion: curDependencies['react-dom'],
51
+ singleton: true,
52
+ eager: true,
53
+ },
54
+ },
55
+ ],
56
+ }),
57
+ ],
58
+ babelPlugins: [
59
+ ['import', { libraryName: 'antd', style: 'css' }], // babel-plugin-import: antd 的按需加载
60
+ ],
38
61
  },
39
62
  preview: {
40
63
  // 用于开启本地预览模式的相关配置信息
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "react-ts-custom-widget-template",
2
+ "name": "react-ts-custom-cmp-template",
3
3
  "version": "1.0.15",
4
4
  "description": "neo自定义组件模板(react&ts技术栈)",
5
5
  "keywords": [
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://git@github.com:wibetter/react-ts-custom-widget-template.git"
34
+ "url": "https://git@github.com:wibetter/react-ts-custom-cmp-template.git"
35
35
  },
36
36
  "bugs": {
37
- "url": "https://github.com/wibetter/react-ts-custom-widget-template/issues"
37
+ "url": "https://github.com/wibetter/react-ts-custom-cmp-template/issues"
38
38
  },
39
39
  "dependencies": {
40
40
  "neo-register": "^1.0.0",
41
- "antd": "^4.9.4",
41
+ "antd": "4.9.4",
42
42
  "react": "^16.9.0",
43
43
  "react-dom": "^16.9.0"
44
44
  },
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.0.2",
50
+ "neo-cmp-cli": "^1.0.3",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- // import { Avatar } from 'antd';
2
+ import { Avatar } from 'antd';
3
+ import { UserOutlined } from '@ant-design/icons';
3
4
  import './style.scss'; // 组件内容样式
4
5
 
5
6
  interface InfoCardProps {
@@ -42,6 +43,7 @@ export default class InfoCard extends React.PureComponent<InfoCardProps> {
42
43
  {title ||
43
44
  '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
44
45
  {systemInfo.tenantName ? `【${systemInfo.tenantName}】` : ''}
46
+ <Avatar size={64} icon={<UserOutlined />} />
45
47
  </div>
46
48
  <div className="item-imgbox">
47
49
  {userInfo && userInfo.icon && (
@@ -12,7 +12,9 @@
12
12
  - 存放在 src/components 目录下的自定义组件,默认 index 为自定义组件源码入口文件,register.[tj]s 为注册 Neo 组件的脚本文件,model.[tj]s 为自定义组件的描述文件(和页面设计器对接需要);
13
13
  - 当 neo.config.js 中的 entry 为空或者不存在时,cli 将根据 src/components 目录下的自定义组件结构生成对应的 entry 配置(可在命令控制台查看生成的 entry 配置);
14
14
  - 自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md);
15
- - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中。
15
+ - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中,避免自定义组件样式相互干扰;
16
+ - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置;
17
+ - 请使用 react 16版本。
16
18
 
17
19
  ### 自定义组件注册器使用说明
18
20
  - [neo-register 使用说明](https://www.npmjs.com/package/neo-register?activeTab=readme)
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "vue2-neo-custom-widget",
2
+ "name": "vue2-custom-cmp-template",
3
3
  "version": "1.1.2",
4
4
  "description": "neo自定义组件模板(vue2.0技术栈)",
5
5
  "keywords": [
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
- "url": "https://git@github.com:wibetter/vue2-neo-custom-widget.git"
34
+ "url": "https://git@github.com:wibetter/vue2-custom-cmp-template.git"
35
35
  },
36
36
  "bugs": {
37
- "url": "https://github.com/wibetter/vue2-neo-custom-widget/issues"
37
+ "url": "https://github.com/wibetter/vue2-custom-cmp-template/issues"
38
38
  },
39
39
  "dependencies": {
40
40
  "neo-register": "^1.0.0",
@@ -44,7 +44,7 @@
44
44
  "devDependencies": {
45
45
  "@commitlint/cli": "^8.3.5",
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
- "neo-cmp-cli": "^1.0.2",
47
+ "neo-cmp-cli": "^1.0.3",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5",
@@ -1,24 +1,24 @@
1
1
  <template>
2
2
  <div class="info-card-container">
3
- <div class="news-title">
4
- {{ title }}
5
- </div>
6
- <div class="item-imgbox">
7
- <div
8
- class="news-img"
9
- :style="{ backgroundImage: 'url(' + backgroundImage + ')' }"
10
- ></div>
11
- <div v-if="img_count > 0" class="img-count">
12
- {{ img_count }}
13
- </div>
3
+ <div class="news-title">
4
+ {{ title }}
5
+ </div>
6
+ <div class="item-imgbox">
7
+ <div
8
+ class="news-img"
9
+ :style="{ backgroundImage: 'url(' + backgroundImage + ')' }"
10
+ ></div>
11
+ <div v-if="img_count > 0" class="img-count">
12
+ {{ img_count }}
14
13
  </div>
15
- <div class="news-info">
16
- <div class="left media-mark">NeoCRM · 低代码平台@Vue2.0组件</div>
17
- <div v-if="comment_count && comment_count != 0" class="cmt-num right">
18
- {{ agreeDataFormat(comment_count) }}评
19
- </div>
14
+ </div>
15
+ <div class="news-info">
16
+ <div class="left media-mark">NeoCRM · 低代码平台@Vue2.0组件</div>
17
+ <div v-if="comment_count && comment_count != 0" class="cmt-num right">
18
+ {{ agreeDataFormat(comment_count) }}评
20
19
  </div>
21
20
  </div>
21
+ </div>
22
22
  </template>
23
23
  <script>
24
24
  // 按需引入element-ui中的组件
@@ -0,0 +1,59 @@
1
+ // 模块联邦插件
2
+ const webpack = require('webpack');
3
+ const { ModuleFederationPlugin } = require('webpack').container;
4
+
5
+ // 解析 webpack 模块联邦 remotes 中的变量
6
+ const ExternalTemplateRemotesPlugin = require('external-remotes-plugin');
7
+
8
+ const { catchCurPackageJson } = require('../utils/pathUtils');
9
+ const getConfigObj = require('../utils/getConfigObj');
10
+
11
+ // 获取当前项目的package文件
12
+ const currentPackageJsonDir = catchCurPackageJson();
13
+ const currentPackageJson = getConfigObj(currentPackageJsonDir);
14
+
15
+ /**
16
+ * Neo 提供的可共享依赖
17
+ * 说明:用于剔除掉自定义组件中的重复依赖,避免重复打包,减少包体积
18
+ */
19
+ const neoSharedDeps = {
20
+ antd: '4.9.4',
21
+ 'antd-mobile': '2.3.4',
22
+ '@ant-design/icons': '^4.8.0',
23
+ axios: '^0.27.2',
24
+ 'angular-expressions': '^1.1.4',
25
+ echarts: '5.4.2',
26
+ mobx: '^6.3.0',
27
+ 'mobx-react': '^7.0.0',
28
+ 'mobx-state-tree': '^5.4.0',
29
+ moment: '^2.25.3',
30
+ lodash: '^4.17.21',
31
+ 'react-dnd': '^11.1.3',
32
+ classnames: '^2.3.2'
33
+ };
34
+
35
+ const MFPlugins = [
36
+ new ModuleFederationPlugin({
37
+ name: currentPackageJson.name,
38
+ remotes: {
39
+ // 通过 external-remotes-plugin 支持变量写法
40
+ neobase: 'neobase@[window.neoEntrys.neobase]',
41
+ neoreact: 'neoreact@[window.neoEntrys.neoreact]'
42
+ }
43
+ }),
44
+ new ExternalTemplateRemotesPlugin(),
45
+ new webpack.NormalModuleReplacementPlugin(/(.*)/, (resource) => {
46
+ if (['react', 'react-dom'].indexOf(resource.request) > -1) {
47
+ // 使用 Neo 提供的 react 和 react-dom
48
+ resource.request = `neoreact/${resource.request}`;
49
+ } else if (neoSharedDeps[resource.request]) {
50
+ // 使用 Neo 提供的其他依赖
51
+ const mfKey = resource.request.replace(/(\/|\.)/gi, '_'); // 换成 neo-ui-mf-base exposes 的 key
52
+ resource.request = `neobase/${mfKey}`;
53
+ }
54
+ })
55
+ ];
56
+
57
+ module.exports = {
58
+ MFPlugins
59
+ };