@maxelms/create-plugin-cli 1.1.0

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 (274) hide show
  1. package/README.en.md +36 -0
  2. package/README.md +12 -0
  3. package/bin/build.js +29 -0
  4. package/bin/compress.js +35 -0
  5. package/bin/copy.js +39 -0
  6. package/bin/index.js +53 -0
  7. package/configuration-schema.json +829 -0
  8. package/lib/index.d.ts +21 -0
  9. package/lib/index.js +242 -0
  10. package/lib/utils.d.ts +18 -0
  11. package/lib/utils.js +114 -0
  12. package/package.json +50 -0
  13. package/templates/jQuery-micro-app/package.json.tpl +19 -0
  14. package/templates/jQuery-micro-app/src/README.md +5 -0
  15. package/templates/jQuery-micro-app/src/configuration.json +30 -0
  16. package/templates/jQuery-micro-app/src/index.html +17 -0
  17. package/templates/jQuery-micro-app/src/main.js.tpl +31 -0
  18. package/templates/jQuery-micro-app/src/manifest.json.tpl +9 -0
  19. package/templates/jQuery-micro-app/src/style.css +11 -0
  20. package/templates/maxelms-navigation/.babelrc +7 -0
  21. package/templates/maxelms-navigation/.gitignore.tpl +23 -0
  22. package/templates/maxelms-navigation/README.md +15 -0
  23. package/templates/maxelms-navigation/global.d.ts +2 -0
  24. package/templates/maxelms-navigation/index.html +16 -0
  25. package/templates/maxelms-navigation/package.json +65 -0
  26. package/templates/maxelms-navigation/patches/live2d-widget@3.1.4.patch +4534 -0
  27. package/templates/maxelms-navigation/pnpm-lock.yaml +7993 -0
  28. package/templates/maxelms-navigation/src/App.tsx +47 -0
  29. package/templates/maxelms-navigation/src/components/Actions/ColorPicker.tsx +86 -0
  30. package/templates/maxelms-navigation/src/components/Actions/SwitchApps.tsx +83 -0
  31. package/templates/maxelms-navigation/src/components/Actions/index.tsx +95 -0
  32. package/templates/maxelms-navigation/src/components/Cutie.tsx +24 -0
  33. package/templates/maxelms-navigation/src/components/Enterprises.tsx +46 -0
  34. package/templates/maxelms-navigation/src/components/Logo.tsx +29 -0
  35. package/templates/maxelms-navigation/src/components/Menus/MenuPanel.tsx +55 -0
  36. package/templates/maxelms-navigation/src/components/Menus/index.tsx +50 -0
  37. package/templates/maxelms-navigation/src/components/Search.tsx +77 -0
  38. package/templates/maxelms-navigation/src/imgs/corp-admin.svg +1 -0
  39. package/templates/maxelms-navigation/src/imgs/saas-admin.svg +1 -0
  40. package/templates/maxelms-navigation/src/imgs/skin.svg +1 -0
  41. package/templates/maxelms-navigation/src/imgs/tenant-admin.svg +1 -0
  42. package/templates/maxelms-navigation/src/imgs/user-center.svg +1 -0
  43. package/templates/maxelms-navigation/src/index.tsx +14 -0
  44. package/templates/maxelms-navigation/src/interface.ts +27 -0
  45. package/templates/maxelms-navigation/src/style.less.tpl +278 -0
  46. package/templates/maxelms-navigation/src/utils.ts.tpl +40 -0
  47. package/templates/maxelms-navigation/tsconfig.json +111 -0
  48. package/templates/maxelms-navigation/webpack.config.js +119 -0
  49. package/templates/maxelms-script/.babelrc +5 -0
  50. package/templates/maxelms-script/.gitignore.tpl +23 -0
  51. package/templates/maxelms-script/README.md +0 -0
  52. package/templates/maxelms-script/global.d.ts +2 -0
  53. package/templates/maxelms-script/index.html +10 -0
  54. package/templates/maxelms-script/package.json.tpl +55 -0
  55. package/templates/maxelms-script/pnpm-lock.yaml +7699 -0
  56. package/templates/maxelms-script/src/App.tsx +15 -0
  57. package/templates/maxelms-script/src/index.tsx +15 -0
  58. package/templates/maxelms-script/src/style.less.tpl +8 -0
  59. package/templates/maxelms-script/src/utils.ts.tpl +2 -0
  60. package/templates/maxelms-script/tsconfig.json +111 -0
  61. package/templates/maxelms-script/webpack.config.js +92 -0
  62. package/templates/maxelms-style/.gitignore.tpl +38 -0
  63. package/templates/maxelms-style/README.md +0 -0
  64. package/templates/maxelms-style/index.css +3 -0
  65. package/templates/maxelms-style/index.less +4 -0
  66. package/templates/maxelms-style/package.json.tpl +17 -0
  67. package/templates/playground/dist/main.css +2 -0
  68. package/templates/playground/dist/main.js +2 -0
  69. package/templates/playground/dist/main.js.LICENSE.txt +52 -0
  70. package/templates/playground/dist/playground.html +1 -0
  71. package/templates/playground/dist/react-dom.production.min.js +2 -0
  72. package/templates/playground/dist/react-dom.production.min.js.LICENSE.txt +8 -0
  73. package/templates/playground/dist/react.production.min.js +2 -0
  74. package/templates/playground/dist/react.production.min.js.LICENSE.txt +8 -0
  75. package/templates/playground/dist/zone.umd.min.js +2 -0
  76. package/templates/playground/dist/zone.umd.min.js.LICENSE.txt +29 -0
  77. package/templates/project/package.json +17 -0
  78. package/templates/react-micro-app/.babelrc +6 -0
  79. package/templates/react-micro-app/.gitignore.tpl +23 -0
  80. package/templates/react-micro-app/README.md +5 -0
  81. package/templates/react-micro-app/manifest.json.tpl +21 -0
  82. package/templates/react-micro-app/package.json.tpl +53 -0
  83. package/templates/react-micro-app/public/configuration.json +30 -0
  84. package/templates/react-micro-app/public/index.html +10 -0
  85. package/templates/react-micro-app/src/components/NoMatch.tsx +15 -0
  86. package/templates/react-micro-app/src/context/masterContext.ts +11 -0
  87. package/templates/react-micro-app/src/index.tsx +52 -0
  88. package/templates/react-micro-app/src/layouts/BasicLayout.less +16 -0
  89. package/templates/react-micro-app/src/layouts/BasicLayout.tsx +21 -0
  90. package/templates/react-micro-app/src/pages/Home/index.less +15 -0
  91. package/templates/react-micro-app/src/pages/Home/index.tsx +33 -0
  92. package/templates/react-micro-app/src/pages/List/index.less +12 -0
  93. package/templates/react-micro-app/src/pages/List/index.tsx +12 -0
  94. package/templates/react-micro-app/src/pages/New/index.less +12 -0
  95. package/templates/react-micro-app/src/pages/New/index.tsx +12 -0
  96. package/templates/react-micro-app/src/pages/View/index.less +12 -0
  97. package/templates/react-micro-app/src/pages/View/index.tsx +12 -0
  98. package/templates/react-micro-app/src/public-path.js +4 -0
  99. package/templates/react-micro-app/src/router.tsx +44 -0
  100. package/templates/react-micro-app/tsconfig.json +102 -0
  101. package/templates/react-micro-app/typings.d.ts +11 -0
  102. package/templates/react-micro-app/webpack.config.js.tpl +178 -0
  103. package/templates/react-micro-app-umi/.editorconfig +16 -0
  104. package/templates/react-micro-app-umi/.env +1 -0
  105. package/templates/react-micro-app-umi/.gitignore.tpl +23 -0
  106. package/templates/react-micro-app-umi/.prettierignore +8 -0
  107. package/templates/react-micro-app-umi/.prettierrc +11 -0
  108. package/templates/react-micro-app-umi/.umirc.ts.tpl +31 -0
  109. package/templates/react-micro-app-umi/README.md +5 -0
  110. package/templates/react-micro-app-umi/manifest.json.tpl +21 -0
  111. package/templates/react-micro-app-umi/package.json.tpl +42 -0
  112. package/templates/react-micro-app-umi/public/basicConfiguration.json +30 -0
  113. package/templates/react-micro-app-umi/public/configuration.json +30 -0
  114. package/templates/react-micro-app-umi/src/layout/BasicLayout.tsx +16 -0
  115. package/templates/react-micro-app-umi/src/pages/about.tsx +11 -0
  116. package/templates/react-micro-app-umi/src/pages/home.tsx +19 -0
  117. package/templates/react-micro-app-umi/tsconfig.json +36 -0
  118. package/templates/react-micro-app-umi/typings.d.ts +8 -0
  119. package/templates/react-micro-button/.gitignore.tpl +23 -0
  120. package/templates/react-micro-button/README.md +5 -0
  121. package/templates/react-micro-button/configuration/Configuration.tsx +113 -0
  122. package/templates/react-micro-button/configuration/index.css +8 -0
  123. package/templates/react-micro-button/configuration/index.tsx +6 -0
  124. package/templates/react-micro-button/manifest.json.tpl +3 -0
  125. package/templates/react-micro-button/package.json.tpl +49 -0
  126. package/templates/react-micro-button/postcss.config.js +5 -0
  127. package/templates/react-micro-button/public/basicConfiguration.json +30 -0
  128. package/templates/react-micro-button/public/configuration.html +10 -0
  129. package/templates/react-micro-button/public/configuration.json +30 -0
  130. package/templates/react-micro-button/public/index.html +10 -0
  131. package/templates/react-micro-button/src/App.tsx +41 -0
  132. package/templates/react-micro-button/src/app.less +0 -0
  133. package/templates/react-micro-button/src/index.less +0 -0
  134. package/templates/react-micro-button/src/index.tsx +30 -0
  135. package/templates/react-micro-button/tsconfig.json +11 -0
  136. package/templates/react-micro-button/webpack.config.js.tpl +150 -0
  137. package/templates/react-micro-field/.babelrc +5 -0
  138. package/templates/react-micro-field/.gitignore.tpl +23 -0
  139. package/templates/react-micro-field/README.md +5 -0
  140. package/templates/react-micro-field/configuration/Configuration.tsx +113 -0
  141. package/templates/react-micro-field/configuration/index.css +8 -0
  142. package/templates/react-micro-field/configuration/index.tsx +6 -0
  143. package/templates/react-micro-field/manifest.json.tpl +7 -0
  144. package/templates/react-micro-field/package.json.tpl +50 -0
  145. package/templates/react-micro-field/postcss.config.js +5 -0
  146. package/templates/react-micro-field/public/basicConfiguration.json +30 -0
  147. package/templates/react-micro-field/public/configuration.html +10 -0
  148. package/templates/react-micro-field/public/configuration.json +30 -0
  149. package/templates/react-micro-field/public/index.html +10 -0
  150. package/templates/react-micro-field/src/App.tsx.tpl +51 -0
  151. package/templates/react-micro-field/src/index.tsx +29 -0
  152. package/templates/react-micro-field/src/style.less.tpl +12 -0
  153. package/templates/react-micro-field/tsconfig.json +11 -0
  154. package/templates/react-micro-field/webpack.config.js.tpl +157 -0
  155. package/templates/react-micro-field-umi/.editorconfig +16 -0
  156. package/templates/react-micro-field-umi/.gitignore.tpl +24 -0
  157. package/templates/react-micro-field-umi/.prettierignore +8 -0
  158. package/templates/react-micro-field-umi/.prettierrc +11 -0
  159. package/templates/react-micro-field-umi/README.md +5 -0
  160. package/templates/react-micro-field-umi/config/config.ts.tpl +41 -0
  161. package/templates/react-micro-field-umi/config/plugin.ts +18 -0
  162. package/templates/react-micro-field-umi/manifest.json.tpl +7 -0
  163. package/templates/react-micro-field-umi/package.json.tpl +48 -0
  164. package/templates/react-micro-field-umi/public/basicConfiguration.json +30 -0
  165. package/templates/react-micro-field-umi/public/configuration.json +30 -0
  166. package/templates/react-micro-field-umi/src/app.tsx +46 -0
  167. package/templates/react-micro-field-umi/src/global.tsx +0 -0
  168. package/templates/react-micro-field-umi/src/hooks/masterProps.ts +33 -0
  169. package/templates/react-micro-field-umi/src/layouts/BasicLayout.tsx +17 -0
  170. package/templates/react-micro-field-umi/src/pages/configuration/index.tsx +90 -0
  171. package/templates/react-micro-field-umi/src/pages/index.tsx.tpl +54 -0
  172. package/templates/react-micro-field-umi/src/pages/interface.ts +12 -0
  173. package/templates/react-micro-field-umi/src/pages/style.less.tpl +15 -0
  174. package/templates/react-micro-field-umi/src/public-path.js +5 -0
  175. package/templates/react-micro-field-umi/tsconfig.json +37 -0
  176. package/templates/react-micro-field-umi/typings.d.ts +10 -0
  177. package/templates/react-micro-plugin/.babelrc +5 -0
  178. package/templates/react-micro-plugin/.gitignore.tpl +23 -0
  179. package/templates/react-micro-plugin/README.md +5 -0
  180. package/templates/react-micro-plugin/configuration/Configuration.tsx +114 -0
  181. package/templates/react-micro-plugin/configuration/index.css +8 -0
  182. package/templates/react-micro-plugin/configuration/index.tsx +6 -0
  183. package/templates/react-micro-plugin/manifest.json.tpl +3 -0
  184. package/templates/react-micro-plugin/package.json.tpl +50 -0
  185. package/templates/react-micro-plugin/postcss.config.js +5 -0
  186. package/templates/react-micro-plugin/public/configuration.html +10 -0
  187. package/templates/react-micro-plugin/public/configuration.json +30 -0
  188. package/templates/react-micro-plugin/public/index.html +10 -0
  189. package/templates/react-micro-plugin/src/App.tsx.tpl +32 -0
  190. package/templates/react-micro-plugin/src/index.tsx +29 -0
  191. package/templates/react-micro-plugin/src/style.less.tpl +12 -0
  192. package/templates/react-micro-plugin/tsconfig.json +11 -0
  193. package/templates/react-micro-plugin/webpack.config.js.tpl +156 -0
  194. package/templates/react-micro-plugin-umi/.editorconfig +16 -0
  195. package/templates/react-micro-plugin-umi/.gitignore.tpl +24 -0
  196. package/templates/react-micro-plugin-umi/.prettierignore +8 -0
  197. package/templates/react-micro-plugin-umi/.prettierrc +11 -0
  198. package/templates/react-micro-plugin-umi/README.md +5 -0
  199. package/templates/react-micro-plugin-umi/config/config.ts +29 -0
  200. package/templates/react-micro-plugin-umi/config/plugin.ts +18 -0
  201. package/templates/react-micro-plugin-umi/manifest.json.tpl +3 -0
  202. package/templates/react-micro-plugin-umi/package.json.tpl +48 -0
  203. package/templates/react-micro-plugin-umi/public/configuration.json +30 -0
  204. package/templates/react-micro-plugin-umi/src/app.tsx +46 -0
  205. package/templates/react-micro-plugin-umi/src/global.tsx +0 -0
  206. package/templates/react-micro-plugin-umi/src/hooks/masterProps.ts +34 -0
  207. package/templates/react-micro-plugin-umi/src/layouts/BasicLayout.tsx +17 -0
  208. package/templates/react-micro-plugin-umi/src/pages/configuration/index.tsx +113 -0
  209. package/templates/react-micro-plugin-umi/src/pages/index.tsx +21 -0
  210. package/templates/react-micro-plugin-umi/src/public-path.js +5 -0
  211. package/templates/react-micro-plugin-umi/tsconfig.json +37 -0
  212. package/templates/react-micro-plugin-umi/typings.d.ts +10 -0
  213. package/templates/vue-micro-app/.gitignore.tpl +23 -0
  214. package/templates/vue-micro-app/README.md +5 -0
  215. package/templates/vue-micro-app/babel.config.js +15 -0
  216. package/templates/vue-micro-app/manifest.json.tpl +21 -0
  217. package/templates/vue-micro-app/package.json.tpl +54 -0
  218. package/templates/vue-micro-app/public/configuration.json +30 -0
  219. package/templates/vue-micro-app/public/favicon.ico +0 -0
  220. package/templates/vue-micro-app/public/index.html +10 -0
  221. package/templates/vue-micro-app/src/App.vue +35 -0
  222. package/templates/vue-micro-app/src/assets/logo.png +0 -0
  223. package/templates/vue-micro-app/src/components/HelloWorld.vue +32 -0
  224. package/templates/vue-micro-app/src/main.js +80 -0
  225. package/templates/vue-micro-app/src/public-path.js +5 -0
  226. package/templates/vue-micro-app/src/routes.js +19 -0
  227. package/templates/vue-micro-app/src/views/About.vue +13 -0
  228. package/templates/vue-micro-app/src/views/Home.vue +21 -0
  229. package/templates/vue-micro-app/vue.config.js.tpl +35 -0
  230. package/templates/vue-micro-button/.gitignore.tpl +23 -0
  231. package/templates/vue-micro-button/README.md +5 -0
  232. package/templates/vue-micro-button/babel.config.js +8 -0
  233. package/templates/vue-micro-button/configuration/App.vue +78 -0
  234. package/templates/vue-micro-button/configuration/main.js +11 -0
  235. package/templates/vue-micro-button/manifest.json.tpl +3 -0
  236. package/templates/vue-micro-button/package.json.tpl +51 -0
  237. package/templates/vue-micro-button/public/basicConfiguration.json +30 -0
  238. package/templates/vue-micro-button/public/configuration.html +10 -0
  239. package/templates/vue-micro-button/public/configuration.json +30 -0
  240. package/templates/vue-micro-button/public/index.html +12 -0
  241. package/templates/vue-micro-button/src/App.vue +46 -0
  242. package/templates/vue-micro-button/src/main.js +44 -0
  243. package/templates/vue-micro-button/vue.config.js.tpl +51 -0
  244. package/templates/vue-micro-field/.gitignore.tpl +23 -0
  245. package/templates/vue-micro-field/README.md +5 -0
  246. package/templates/vue-micro-field/babel.config.js +8 -0
  247. package/templates/vue-micro-field/configuration/App.vue +78 -0
  248. package/templates/vue-micro-field/configuration/main.js +11 -0
  249. package/templates/vue-micro-field/manifest.json.tpl +7 -0
  250. package/templates/vue-micro-field/package.json.tpl +53 -0
  251. package/templates/vue-micro-field/public/basicConfiguration.json +30 -0
  252. package/templates/vue-micro-field/public/configuration.html +10 -0
  253. package/templates/vue-micro-field/public/configuration.json +30 -0
  254. package/templates/vue-micro-field/public/index.html +10 -0
  255. package/templates/vue-micro-field/scripts/compress.js +32 -0
  256. package/templates/vue-micro-field/src/App.vue.tpl +55 -0
  257. package/templates/vue-micro-field/src/main.js +38 -0
  258. package/templates/vue-micro-field/src/style.less.tpl +16 -0
  259. package/templates/vue-micro-field/vue.config.js.tpl +51 -0
  260. package/templates/vue-micro-plugin/.gitignore.tpl +23 -0
  261. package/templates/vue-micro-plugin/README.md +24 -0
  262. package/templates/vue-micro-plugin/babel.config.js +8 -0
  263. package/templates/vue-micro-plugin/configuration/App.vue +100 -0
  264. package/templates/vue-micro-plugin/configuration/main.js +11 -0
  265. package/templates/vue-micro-plugin/manifest.json.tpl +3 -0
  266. package/templates/vue-micro-plugin/package.json.tpl +56 -0
  267. package/templates/vue-micro-plugin/public/configuration.html +10 -0
  268. package/templates/vue-micro-plugin/public/configuration.json +30 -0
  269. package/templates/vue-micro-plugin/public/index.html +10 -0
  270. package/templates/vue-micro-plugin/scripts/compress.js +32 -0
  271. package/templates/vue-micro-plugin/src/App.vue.tpl +42 -0
  272. package/templates/vue-micro-plugin/src/main.js +38 -0
  273. package/templates/vue-micro-plugin/src/style.less.tpl +16 -0
  274. package/templates/vue-micro-plugin/vue.config.js.tpl +53 -0
@@ -0,0 +1,178 @@
1
+ // Generated using webpack-cli https://github.com/webpack/webpack-cli
2
+
3
+ const path = require('path');
4
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
5
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
6
+ const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
7
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
8
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
9
+ const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
10
+
11
+ const isProduction = process.env.NODE_ENV == 'production';
12
+
13
+ const stylesHandler = MiniCssExtractPlugin.loader;
14
+
15
+ /**
16
+ * Maxelms 平台默认提供 react react-dom 的 umd 资源
17
+ * 配置 externals 可以减少打包时间,提升加载性能
18
+ **/
19
+
20
+ const externals = false ? {
21
+ "react": {
22
+ commonjs: '__MAXELMS_SHARE_MODULES__',
23
+ commonjs2: '__MAXELMS_SHARE_MODULES__',
24
+ root: ['__MAXELMS_SHARE_MODULES__', 'React']
25
+ },
26
+ "react-dom": {
27
+ commonjs: '__MAXELMS_SHARE_MODULES__',
28
+ commonjs2: '__MAXELMS_SHARE_MODULES__',
29
+ root: ['__MAXELMS_SHARE_MODULES__', 'ReactDOM']
30
+ },
31
+ "lodash": {
32
+ commonjs: '__MAXELMS_SHARE_MODULES__',
33
+ commonjs2: '__MAXELMS_SHARE_MODULES__',
34
+ root: ['__MAXELMS_SHARE_MODULES__', 'lodash']
35
+ },
36
+ } : {}
37
+
38
+
39
+ const config = {
40
+ entry: './src/index.tsx',
41
+ output: {
42
+ publicPath: '',
43
+ path: path.resolve(__dirname, 'dist'),
44
+ libraryTarget: 'umd',
45
+ library: "<%= pluginName %>-<%= uniqueIdentifier %>",
46
+ },
47
+ externals,
48
+ devServer: {
49
+ port: 9000,
50
+ open: true,
51
+ host: 'localhost',
52
+ headers: {
53
+ "Access-Control-Allow-Origin": '*'
54
+ }
55
+ },
56
+ plugins: [
57
+ new MomentLocalesPlugin(),
58
+ new HtmlWebpackPlugin({
59
+ template: 'public/index.html',
60
+ }),
61
+ new CopyWebpackPlugin({
62
+ patterns: [{
63
+ from: 'public',
64
+ globOptions: {
65
+ dot: true,
66
+ gitignore: true,
67
+ ignore: ['**/public/index.html'],
68
+ },
69
+ noErrorOnMissing: true,
70
+ },
71
+ {
72
+ from: 'README.md'
73
+ },
74
+ {
75
+ from: 'manifest.json'
76
+ },
77
+ ],
78
+ }),
79
+ new MiniCssExtractPlugin(),
80
+
81
+ // Add your plugins here
82
+ // Learn more about plugins from https://webpack.js.org/configuration/plugins/
83
+ ],
84
+ module: {
85
+ rules: [{
86
+ test: /\.(ts|tsx)$/i,
87
+ use: [{
88
+ loader: 'babel-loader',
89
+ options: {
90
+ presets: ['@babel/preset-react']
91
+ }
92
+ },
93
+ 'ts-loader',
94
+ ],
95
+ exclude: ['/node_modules/'],
96
+ },
97
+ {
98
+ test: /\.less$/i,
99
+ use: [stylesHandler, {
100
+ loader: 'css-loader',
101
+ options: {
102
+ modules: {
103
+ auto: path => !path.includes("node_modules"),
104
+ localIdentName: '[local]_[hash:base64:16]'
105
+ }
106
+ }
107
+ }, 'postcss-loader', {
108
+ loader: 'less-loader',
109
+ options: {
110
+ lessOptions: {
111
+ javascriptEnabled: true
112
+ }
113
+ }
114
+ }],
115
+ },
116
+ {
117
+ test: /\.css$/i,
118
+ use: [stylesHandler, {
119
+ loader: 'css-loader',
120
+ options: {
121
+ modules: {
122
+ auto: path => !path.includes("node_modules"),
123
+ localIdentName: '[local]_[hash:base64:16]'
124
+ }
125
+ }
126
+ }, 'postcss-loader'],
127
+ },
128
+ {
129
+ test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
130
+ type: 'asset',
131
+ },
132
+
133
+ // Add your rules for custom modules here
134
+ // Learn more about loaders from https://webpack.js.org/loaders/
135
+ ],
136
+ },
137
+ resolve: {
138
+ extensions: ['.tsx', '.ts', '.js'],
139
+ alias: {
140
+ '@': path.resolve('src')
141
+ }
142
+ },
143
+ optimization: {
144
+ minimizer: [
145
+ `...`,
146
+ new CssMinimizerPlugin(),
147
+ new ImageMinimizerPlugin({
148
+ test: /screenshots\/.*\.(jpe?g|png|avif)$/i,
149
+ minimizer: {
150
+ implementation: ImageMinimizerPlugin.squooshMinify,
151
+ options: {
152
+ encodeOptions: {
153
+ mozjpeg: {
154
+ quality: 15,
155
+ },
156
+ avif: {
157
+ cqLevel: 18,
158
+ speed: 6
159
+ },
160
+ oxipng: {
161
+ level: 2,
162
+ }
163
+ },
164
+ },
165
+ },
166
+ }),
167
+ ],
168
+ },
169
+ };
170
+
171
+ module.exports = () => {
172
+ if (isProduction) {
173
+ config.mode = 'production';
174
+ } else {
175
+ config.mode = 'development';
176
+ }
177
+ return config;
178
+ };
@@ -0,0 +1,16 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [Makefile]
16
+ indent_style = tab
@@ -0,0 +1 @@
1
+ PORT=8001
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /npm-debug.log*
6
+ /yarn-error.log
7
+ /yarn.lock
8
+ /package-lock.json
9
+
10
+ # production
11
+ /dist
12
+
13
+ # misc
14
+ .DS_Store
15
+
16
+ # umi
17
+ /src/.umi
18
+ /src/.umi-production
19
+ /src/.umi-test
20
+ /.env.local
21
+ /dist.maxplugin
22
+ /dist.zip
23
+ /.vscode
@@ -0,0 +1,8 @@
1
+ **/*.md
2
+ **/*.svg
3
+ **/*.ejs
4
+ **/*.html
5
+ package.json
6
+ .umi
7
+ .umi-production
8
+ .umi-test
@@ -0,0 +1,11 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 80,
5
+ "overrides": [
6
+ {
7
+ "files": ".prettierrc",
8
+ "options": { "parser": "json" }
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,31 @@
1
+ import { defineConfig } from 'umi';
2
+
3
+ export default defineConfig({
4
+ nodeModulesTransform: {
5
+ type: 'none',
6
+ },
7
+ history: {
8
+ type: 'hash'
9
+ },
10
+ publicPath: './',
11
+ routes: [
12
+ { path: '/', component: '@/layout/BasicLayout',
13
+ routes: [
14
+ { path: '/', component: '@/pages/home' },
15
+ { path: '/about', component: '@/pages/about' },
16
+ ]
17
+ },
18
+ ],
19
+ fastRefresh: {},
20
+ qiankun: {
21
+ slave: {},
22
+ },
23
+ copy: [
24
+ 'README.md',
25
+ 'manifest.json'
26
+ ],
27
+ chainWebpack(config:any) {
28
+ const umdUniqueIdentifier = '<%= pluginName %>-<%= uniqueIdentifier %>';
29
+ config.output.library(umdUniqueIdentifier).libraryTarget('umd').jsonpFunction(umdUniqueIdentifier);
30
+ }
31
+ });
@@ -0,0 +1,5 @@
1
+ # Maxelms MicroApp
2
+
3
+ ## 功能介绍
4
+
5
+ ## 使用说明
@@ -0,0 +1,21 @@
1
+ {
2
+ "routes": [
3
+ {
4
+ "title": "首页",
5
+ "value": "/"
6
+ },
7
+ {
8
+ "title": "列表页",
9
+ "value": "/list"
10
+ },
11
+ {
12
+ "title": "详情页",
13
+ "value": "/view"
14
+ },
15
+ {
16
+ "title": "新建页",
17
+ "value": "/new"
18
+ }
19
+ ],
20
+ "deviceTypes": ["pc"]
21
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "scripts": {
4
+ "start": "umi dev",
5
+ "build": "umi build && maxelms-plugin-cli -c",
6
+ "postinstall": "umi generate tmp",
7
+ "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
8
+ "test": "umi-test",
9
+ "test:coverage": "umi-test --coverage"
10
+ },
11
+ "gitHooks": {
12
+ "pre-commit": "lint-staged"
13
+ },
14
+ "lint-staged": {
15
+ "*.{js,jsx,less,md,json}": [
16
+ "prettier --write"
17
+ ],
18
+ "*.ts?(x)": [
19
+ "prettier --parser=typescript --write"
20
+ ]
21
+ },
22
+ "dependencies": {
23
+ "@ant-design/pro-layout": "6.5.0",
24
+ "@umijs/plugin-qiankun": "2.35.4",
25
+ "@umijs/preset-react": "1.x",
26
+ "archiver": "5.3.1",
27
+ "lodash": "4.17.21",
28
+ "react": "16.14.0",
29
+ "react-dom": "16.14.0",
30
+ "umi": "3.4.8"
31
+ },
32
+ "devDependencies": {
33
+ "@maxelms/create-plugin-cli": "<%= cliVersion %>",
34
+ "@types/react": "17.0.0",
35
+ "@types/react-dom": "17.0.0",
36
+ "@umijs/test": "3.4.8",
37
+ "lint-staged": "10.0.7",
38
+ "prettier": "2.2.0",
39
+ "typescript": "4.1.2",
40
+ "yorkie": "2.0.0"
41
+ }
42
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "propName1": {
3
+ "label": "配置项一",
4
+ "type": "string",
5
+ "defaultValue": "配置项内容"
6
+ },
7
+ "propName2": {
8
+ "label": "配置项二",
9
+ "type": "number",
10
+ "defaultValue": 350
11
+ },
12
+ "propName3": {
13
+ "label": "配置项三",
14
+ "type": "select",
15
+ "options": [
16
+ {
17
+ "label": "选项1",
18
+ "value": "option1"
19
+ },
20
+ {
21
+ "label": "选项2",
22
+ "value": "option2"
23
+ },
24
+ {
25
+ "label": "选项3",
26
+ "value": "option3"
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "propName1": {
3
+ "label": "配置项一",
4
+ "type": "string",
5
+ "defaultValue": "配置项内容"
6
+ },
7
+ "propName2": {
8
+ "label": "配置项二",
9
+ "type": "number",
10
+ "defaultValue": 350
11
+ },
12
+ "propName3": {
13
+ "label": "配置项三",
14
+ "type": "select",
15
+ "options": [
16
+ {
17
+ "label": "选项1",
18
+ "value": "option1"
19
+ },
20
+ {
21
+ "label": "选项2",
22
+ "value": "option2"
23
+ },
24
+ {
25
+ "label": "选项3",
26
+ "value": "option3"
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import { Link } from 'umi'
3
+
4
+ const BasicLayout: React.FC<{}> = props => {
5
+
6
+ return (
7
+ <div>
8
+ <Link to="/">home</Link>
9
+ |
10
+ <Link to="/about">about</Link>
11
+ {props.children}
12
+ </div>
13
+ )
14
+ }
15
+
16
+ export default BasicLayout
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+
3
+ const About = () => {
4
+ return (
5
+ <div>
6
+ About
7
+ </div>
8
+ )
9
+ }
10
+
11
+ export default About
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import { useModel } from 'umi'
3
+
4
+ const Home = () => {
5
+ const qiankunStateFromMaster = useModel('@@qiankunStateFromMaster')
6
+ /**
7
+ * masterGlobalState 是基座应用传递给子应用的属性
8
+ * setMasterGlobalState 可更改属性值
9
+ */
10
+ const { masterGlobalState, setMasterGlobalState } = qiankunStateFromMaster || {}
11
+
12
+ return (
13
+ <div>
14
+ Home
15
+ </div>
16
+ )
17
+ }
18
+
19
+ export default Home
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "importHelpers": true,
7
+ "jsx": "react-jsx",
8
+ "esModuleInterop": true,
9
+ "sourceMap": true,
10
+ "baseUrl": "./",
11
+ "strict": true,
12
+ "paths": {
13
+ "@/*": ["src/*"],
14
+ "@@/*": ["src/.umi/*"]
15
+ },
16
+ "allowSyntheticDefaultImports": true
17
+ },
18
+ "include": [
19
+ "mock/**/*",
20
+ "src/**/*",
21
+ "config/**/*",
22
+ ".umirc.ts",
23
+ "typings.d.ts"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "lib",
28
+ "es",
29
+ "dist",
30
+ "typings",
31
+ "**/__test__",
32
+ "test",
33
+ "docs",
34
+ "tests"
35
+ ]
36
+ }
@@ -0,0 +1,8 @@
1
+ declare module '*.css';
2
+ declare module '*.less';
3
+ declare module '*.png';
4
+ declare module '*.svg' {
5
+ export function ReactComponent(props: React.SVGProps<SVGSVGElement>): React.ReactElement
6
+ const url: string
7
+ export default url
8
+ }
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /npm-debug.log*
6
+ /yarn-error.log
7
+ /yarn.lock
8
+ /package-lock.json
9
+
10
+ # production
11
+ /dist
12
+
13
+ # misc
14
+ .DS_Store
15
+
16
+ # umi
17
+ /src/.umi
18
+ /src/.umi-production
19
+ /src/.umi-test
20
+ /.env.local
21
+ /dist.maxplugin
22
+ /dist.zip
23
+ /.vscode
@@ -0,0 +1,5 @@
1
+ # Maxelms Custom Button
2
+
3
+ ## 功能介绍
4
+
5
+ ## 使用说明
@@ -0,0 +1,113 @@
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { Form, Switch, Input, InputNumber, Select } from 'antd';
3
+ import { PluginChannel } from '@max-kit/max-api'
4
+
5
+ interface ConfigurationType {}
6
+ type PlainObject = Record<string, any>
7
+ interface FieldData {
8
+ pathChain: string;
9
+ fieldId: string;
10
+ fieldName: string;
11
+ objId: string;
12
+ objName: string;
13
+ type: string;
14
+ }
15
+
16
+ const initFormValues:PlainObject = {
17
+ size: 'default',
18
+ disabled: false,
19
+ placeholder: '',
20
+ maxLength: null,
21
+ label: '',
22
+ }
23
+
24
+ const Configuration: React.FC<ConfigurationType> = () => {
25
+ const [form] = Form.useForm()
26
+
27
+ const pluginChannelRef = useRef(null)
28
+
29
+ const [fields, setFields] = useState<FieldData[]>([])
30
+
31
+ useEffect(() => {
32
+ const channel = new PluginChannel({
33
+ init: initConfigs
34
+ })
35
+
36
+ pluginChannelRef.current = channel
37
+ getFormFieldsAsync(channel)
38
+ return () => {
39
+ channel.destroy()
40
+ }
41
+ }, []);
42
+
43
+ const initConfigs = (configs:PlainObject) => {
44
+ if (!configs || typeof configs !== 'object') return
45
+ if (typeof configs.field === 'object') configs.field = configs.field.pathChain
46
+ form.setFieldsValue(configs)
47
+ }
48
+
49
+ const submitConfig = () => {
50
+ const configs = form.getFieldsValue()
51
+ const { field } = configs
52
+ if (field) {
53
+ const fieldDetail = fields.find(item => item.pathChain === field)
54
+ if (fieldDetail) configs.field = fieldDetail
55
+ }
56
+ pluginChannelRef.current && pluginChannelRef.current.update(configs)
57
+ };
58
+
59
+ const getFormFieldsAsync = (channel: PluginChannel) => {
60
+ channel.emit('getFormFieldsValueAsync').then((data: FieldData[]) => {
61
+ setFields(data)
62
+ }).catch(err => {
63
+ console.log('err: ', err)
64
+ })
65
+ }
66
+
67
+ return (
68
+ <Form layout="vertical" form={form} initialValues={initFormValues} onFieldsChange={submitConfig} style={{padding: '10px'}}>
69
+ <Form.Item name="disabled" label="是否禁用" valuePropName="checked">
70
+ <Switch />
71
+ </Form.Item>
72
+ <Form.Item name="maxLength" label="最大长度">
73
+ <InputNumber />
74
+ </Form.Item>
75
+ <Form.Item name="size" label="控件大小">
76
+ <Select
77
+ options={[
78
+ {
79
+ label: 'default',
80
+ value: 'default',
81
+ },
82
+ {
83
+ label: 'small',
84
+ value: 'small',
85
+ },
86
+ {
87
+ label: 'large',
88
+ value: 'large',
89
+ },
90
+ ]}
91
+ />
92
+ </Form.Item>
93
+ <Form.Item name="placeholder" label="占位符">
94
+ <Input />
95
+ </Form.Item>
96
+ <Form.Item name="label" label="label">
97
+ <Input />
98
+ </Form.Item>
99
+ <Form.Item name="field" label="绑定字段">
100
+ <Select
101
+ options={fields.map((field) => {
102
+ return {
103
+ label: field.fieldName,
104
+ value: field.pathChain
105
+ }
106
+ })}
107
+ />
108
+ </Form.Item>
109
+ </Form>
110
+ );
111
+ };
112
+
113
+ export default Configuration;
@@ -0,0 +1,8 @@
1
+ body {
2
+ margin: 0;
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+ sans-serif;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import Configuration from './Configuration';
4
+ import './index.css';
5
+
6
+ ReactDOM.render(<Configuration />, document.getElementById('root'));
@@ -0,0 +1,3 @@
1
+ {
2
+ "configurationType": "<%= configurationType %>"
3
+ }