neo-cmp-cli 1.0.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 (76) hide show
  1. package/README.md +236 -0
  2. package/bin/neo.js +2 -0
  3. package/package.json +74 -0
  4. package/src/config/default.config.js +136 -0
  5. package/src/config/index.js +9 -0
  6. package/src/initData/defaultTemplate.html +13 -0
  7. package/src/initData/neo.config.js +99 -0
  8. package/src/module/index.js +244 -0
  9. package/src/module/inspect.js +40 -0
  10. package/src/module/main.js +109 -0
  11. package/src/module/neoInit.js +44 -0
  12. package/src/module/neoInitByCopy.js +37 -0
  13. package/src/oss/publish2oss.js +218 -0
  14. package/src/plugins/README.md +2 -0
  15. package/src/template/react-custom-widget-template/.editorconfig +10 -0
  16. package/src/template/react-custom-widget-template/.prettierrc.js +12 -0
  17. package/src/template/react-custom-widget-template/README.md +51 -0
  18. package/src/template/react-custom-widget-template/commitlint.config.js +59 -0
  19. package/src/template/react-custom-widget-template/neo.config.js +112 -0
  20. package/src/template/react-custom-widget-template/package.json +56 -0
  21. package/src/template/react-custom-widget-template/public/css/base.css +283 -0
  22. package/src/template/react-custom-widget-template/public/scripts/app/bluebird.js +6679 -0
  23. package/src/template/react-custom-widget-template/public/template.html +13 -0
  24. package/src/template/react-custom-widget-template/src/assets/css/common.scss +127 -0
  25. package/src/template/react-custom-widget-template/src/assets/css/mixin.scss +47 -0
  26. package/src/template/react-custom-widget-template/src/components/info-card/index.jsx +45 -0
  27. package/src/template/react-custom-widget-template/src/components/info-card/model.js +81 -0
  28. package/src/template/react-custom-widget-template/src/components/info-card/register.js +4 -0
  29. package/src/template/react-custom-widget-template/src/components/info-card/style.scss +67 -0
  30. package/src/template/react-custom-widget-template/src/preview.js +5 -0
  31. package/src/template/react-ts-custom-widget-template/.editorconfig +10 -0
  32. package/src/template/react-ts-custom-widget-template/.prettierrc.js +12 -0
  33. package/src/template/react-ts-custom-widget-template/README.md +53 -0
  34. package/src/template/react-ts-custom-widget-template/commitlint.config.js +59 -0
  35. package/src/template/react-ts-custom-widget-template/neo.config.js +106 -0
  36. package/src/template/react-ts-custom-widget-template/package.json +59 -0
  37. package/src/template/react-ts-custom-widget-template/public/css/base.css +283 -0
  38. package/src/template/react-ts-custom-widget-template/public/scripts/app/bluebird.js +6679 -0
  39. package/src/template/react-ts-custom-widget-template/public/template.html +13 -0
  40. package/src/template/react-ts-custom-widget-template/src/assets/css/common.scss +127 -0
  41. package/src/template/react-ts-custom-widget-template/src/assets/css/mixin.scss +47 -0
  42. package/src/template/react-ts-custom-widget-template/src/components/info-card/index.tsx +70 -0
  43. package/src/template/react-ts-custom-widget-template/src/components/info-card/plugin.ts +80 -0
  44. package/src/template/react-ts-custom-widget-template/src/components/info-card/register.ts +5 -0
  45. package/src/template/react-ts-custom-widget-template/src/components/info-card/style.scss +105 -0
  46. package/src/template/react-ts-custom-widget-template/src/components/list-widget/README.md +2 -0
  47. package/src/template/react-ts-custom-widget-template/src/components/list-widget/index.tsx +208 -0
  48. package/src/template/react-ts-custom-widget-template/src/components/list-widget/model.ts +92 -0
  49. package/src/template/react-ts-custom-widget-template/src/components/list-widget/register.ts +5 -0
  50. package/src/template/react-ts-custom-widget-template/src/components/list-widget/style.scss +350 -0
  51. package/src/template/react-ts-custom-widget-template/src/preview.tsx +37 -0
  52. package/src/template/react-ts-custom-widget-template/tsconfig.json +68 -0
  53. package/src/template/vue2-neo-custom-widget/.editorconfig +10 -0
  54. package/src/template/vue2-neo-custom-widget/.prettierrc.js +12 -0
  55. package/src/template/vue2-neo-custom-widget/README.md +52 -0
  56. package/src/template/vue2-neo-custom-widget/commitlint.config.js +59 -0
  57. package/src/template/vue2-neo-custom-widget/neo.config.js +122 -0
  58. package/src/template/vue2-neo-custom-widget/package.json +59 -0
  59. package/src/template/vue2-neo-custom-widget/public/css/base.css +283 -0
  60. package/src/template/vue2-neo-custom-widget/public/scripts/app/bluebird.js +6679 -0
  61. package/src/template/vue2-neo-custom-widget/public/template.html +13 -0
  62. package/src/template/vue2-neo-custom-widget/src/assets/css/common.scss +126 -0
  63. package/src/template/vue2-neo-custom-widget/src/assets/css/mixin.scss +47 -0
  64. package/src/template/vue2-neo-custom-widget/src/preview.js +9 -0
  65. package/src/template/vue2-neo-custom-widget/src/widgets/info-card/index.vue +131 -0
  66. package/src/template/vue2-neo-custom-widget/src/widgets/info-card/plugin.js +81 -0
  67. package/src/template/vue2-neo-custom-widget/src/widgets/info-card/register.js +8 -0
  68. package/src/utils/getConfigObj.js +18 -0
  69. package/src/utils/getEntries.js +54 -0
  70. package/src/utils/neoConfigInit.js +13 -0
  71. package/src/utils/neoParams.js +12 -0
  72. package/src/utils/pathUtils.js +23 -0
  73. package/src/utils/projectNameValidator.js +76 -0
  74. package/src/utils/replaceInFiles.js +47 -0
  75. package/src/utils/replaceInPackage.js +134 -0
  76. package/test/demo.js +3 -0
@@ -0,0 +1,13 @@
1
+ <html lang="en">
2
+ <head>
3
+ <meta charset="UTF-8">
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
+ <meta name="format-detection" content="telephone=no"/>
6
+ <meta name="viewport" content="initial-scale=1.0,user-scalable=no,width=device-width,viewport-fit=cover">
7
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
+ <title>自定义组件预览页</title>
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,127 @@
1
+ /* 公共的自定义函数 */
2
+
3
+ @function px2vw($px, $screen-width: 750) {
4
+ @return ($px / $screen-width) * 100vw;
5
+ }
6
+
7
+ @function px2rem($px, $remRate: 100) {
8
+ @return ($px / $remRate) + rem;
9
+ }
10
+
11
+ @function px2vmin($px, $screen-width: 750) {
12
+ @return ($px / $screen-width) * 100vmin;
13
+ }
14
+
15
+ @mixin fillBox {
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+
20
+ /* 头部细线 */
21
+ @mixin borderTop {
22
+ content: '';
23
+ position: absolute;
24
+ left: 0;
25
+ right: 0;
26
+ top: 0;
27
+ width: 100%;
28
+ height: 1px;
29
+ background: #ddd;
30
+ transform: scaleY(0.5);
31
+ }
32
+
33
+ /* 底部细线 */
34
+ @mixin borderBtm {
35
+ content: '';
36
+ position: absolute;
37
+ left: 0;
38
+ right: 0;
39
+ bottom: 0;
40
+ width: 100%;
41
+ height: 1px;
42
+ background: #ddd;
43
+ transform: scaleY(0.5);
44
+ }
45
+
46
+ /* 统一的内边距 */
47
+ @mixin unifiedPadding($value: 40) {
48
+ padding: 0 px2rem($value) 0 px2rem($value);
49
+ }
50
+
51
+ /* 统一的左内边距 */
52
+ @mixin unifiedLeftPadding($value: 40) {
53
+ padding-left: px2rem($value);
54
+ }
55
+
56
+ /* 统一的右内边距 */
57
+ @mixin unifiedRightPadding($value: 40) {
58
+ padding-right: px2rem($value);
59
+ }
60
+
61
+ /* 统一的底部边框样式 */
62
+ @mixin unifiedBottomBorder {
63
+ border-bottom: 1px solid #ddd;
64
+ }
65
+
66
+ /* 统一的上边框样式 */
67
+ @mixin unifiedTopBorder {
68
+ border-top: 1px solid #ddd;
69
+ }
70
+
71
+ /* 统一的Item高度 */
72
+ @mixin unifiedItemHeight {
73
+ line-height: px2rem(120);
74
+ height: px2rem(120);
75
+ }
76
+
77
+ /* 设置行高样式 */
78
+ @mixin setItemHeight($value: 120) {
79
+ line-height: px2rem($value);
80
+ height: px2rem($value);
81
+ }
82
+
83
+ /* 统一的Item样式 */
84
+ @mixin unifiedItemStyle {
85
+ font-family: PingFangSC-Regular;
86
+ font-size: px2rem(28);
87
+ color: #828282;
88
+ letter-spacing: 0;
89
+ }
90
+
91
+ /* 统一的弹性盒子样式 */
92
+ @mixin unifiedFlexBoxStyle {
93
+ display: flex;
94
+ flex-wrap: nowrap;
95
+ justify-content: center;
96
+ align-items: center;
97
+ }
98
+
99
+ /* 统一的Title样式 */
100
+ @mixin unifiedTitleStyle {
101
+ font-family: PingFangSC-Regular;
102
+ font-size: px2rem(40);
103
+ color: #1e1e1e;
104
+ }
105
+
106
+ /* 统一的内容样式 */
107
+ @mixin unifiedContentStyle {
108
+ font-family: PingFangSC-Regular;
109
+ font-size: px2rem(28);
110
+ color: #1e1e1e;
111
+ letter-spacing: 0;
112
+ text-align: right;
113
+ line-height: px2rem(28);
114
+ }
115
+
116
+ /* 底部导航盒子样式 */
117
+ @mixin fixedBottomBox {
118
+ position: fixed;
119
+ left: 0;
120
+ bottom: 0;
121
+ width: 100%;
122
+ }
123
+
124
+ // 常用的变量
125
+ $background-color: #fafafa;
126
+ $border-color: #f7f7f7;
127
+ $page-padding-top: px2rem(20);
@@ -0,0 +1,47 @@
1
+ // 通用mixin
2
+ $borderColor: #ddd;
3
+
4
+ // type 为top 或者 bottom
5
+ @mixin borderTopOrBtm($type) {
6
+ &::after {
7
+ content: '';
8
+ position: absolute;
9
+ left: 0;
10
+ right: 0;
11
+ #{$type}: 0;
12
+ width: 100%;
13
+ height: 1px;
14
+ background: $borderColor;
15
+ transform: scaleY(0.5);
16
+ }
17
+ }
18
+
19
+ // type为 right 或者 left
20
+ @mixin borderRtOrLt($type) {
21
+ &::after {
22
+ content: '';
23
+ position: absolute;
24
+ top: 0;
25
+ bottom: 0;
26
+ #{$type}: 0;
27
+ height: 100%;
28
+ width: 1px;
29
+ background: $borderColor;
30
+ transform: scaleX(0.5);
31
+ }
32
+ }
33
+
34
+ //超出1行显示...
35
+ @mixin ellipsis1 {
36
+ overflow: hidden;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap;
39
+ }
40
+
41
+ // 超出多行显示...
42
+ @mixin ellipsis($num) {
43
+ overflow: hidden;
44
+ display: -webkit-box;
45
+ -webkit-line-clamp: $num;
46
+ -webkit-box-orient: vertical;
47
+ }
@@ -0,0 +1,45 @@
1
+ import * as React from 'react';
2
+ import './style.scss'; // 组件内容样式
3
+
4
+ export default class InfoCard extends React.PureComponent {
5
+ constructor() {
6
+ super();
7
+ this.agreeDataFormat = this.agreeDataFormat.bind(this);
8
+ }
9
+ agreeDataFormat(agreeData) {
10
+ if (agreeData && agreeData <= 9999) {
11
+ return agreeData;
12
+ }
13
+ if (agreeData && agreeData > 9999) {
14
+ return `${Math.floor(agreeData / 1000) / 10}w`;
15
+ }
16
+ }
17
+ render() {
18
+ const { title, backgroundImage, imgCount, commentCount } = this.props;
19
+ const curBackgroundImage =
20
+ backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
21
+ return (
22
+ <div className="info-card-container">
23
+ <div className="news-title">
24
+ {title ||
25
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
26
+ </div>
27
+ <div className="item-imgbox">
28
+ <div
29
+ className="news-img"
30
+ style={{ backgroundImage: `url(${curBackgroundImage})` }}
31
+ ></div>
32
+ {imgCount > 0 && <div className="img-count">{imgCount}</div>}
33
+ </div>
34
+ <div className="news-info">
35
+ <div className="left media-mark">NeoCRM · 低代码平台</div>
36
+ {commentCount && commentCount > 0 && (
37
+ <div className="cmt-num right">
38
+ {this.agreeDataFormat(commentCount)}评
39
+ </div>
40
+ )}
41
+ </div>
42
+ </div>
43
+ );
44
+ }
45
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @file 自定义组件对接编辑器的描述文件
3
+ */
4
+ // @ts-ignore
5
+ import { registerNeoEditorModel } from 'neo-register';
6
+
7
+ export class InfoCardModel {
8
+ // 自定义组件名称,用于标识组件的唯一性
9
+ cmpType = 'info-card';
10
+
11
+ // 组件名称,用于设置在编辑器左侧组件面板中展示的名称
12
+ label = '信息卡片';
13
+
14
+ // 组件描述,用于设置在编辑器左侧组件面板中展示的描述
15
+ description = '信息展示卡片';
16
+
17
+ // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
+ tags = ['自定义组件'];
19
+
20
+ // 组件图标,用于设置在编辑器左侧组件面板中展示的图标
21
+ // iconSrc = 'https://neo-widgets.bj.bcebos.com/custom-widget.svg';
22
+ iconSrc = 'https://neo-widgets.bj.bcebos.com/favicon.png';
23
+
24
+ // 初次插入页面的默认属性数据
25
+ defaultComProps = {
26
+ title:
27
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。',
28
+ label: '信息卡片',
29
+ backgroundImage: 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg',
30
+ imgCount: 3,
31
+ commentCount: 2025,
32
+ };
33
+
34
+ // 设计器端预览时展示的默认数据
35
+ previewComProps = {
36
+ label: '信息卡片',
37
+ };
38
+
39
+ /**
40
+ * 组件面板配置,用于生成编辑器右侧属性配置面板内容
41
+ * 备注:自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md
42
+ */
43
+ propsSchema = [
44
+ {
45
+ type: 'textarea',
46
+ name: 'title',
47
+ label: '卡片title',
48
+ value:
49
+ '营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。',
50
+ },
51
+ {
52
+ type: 'text',
53
+ name: 'backgroundImage',
54
+ label: '展示图片',
55
+ value: 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg',
56
+ },
57
+ {
58
+ type: 'number',
59
+ name: 'imgCount',
60
+ label: '图片数量',
61
+ value: 3,
62
+ },
63
+ {
64
+ type: 'number',
65
+ name: 'commentCount',
66
+ label: '评论数',
67
+ value: 2025,
68
+ },
69
+ ];
70
+
71
+ // 支持 函数式写法:propsSchemaCreator,com 为页面设计器中的组件实例。优先级比 propsSchema 高
72
+ /*
73
+ propsSchemaCreator = (com: any, data: any) => {
74
+ return [];
75
+ };
76
+ */
77
+ }
78
+
79
+ registerNeoEditorModel(InfoCardModel);
80
+
81
+ export default InfoCardModel;
@@ -0,0 +1,4 @@
1
+ import InfoCard from './index';
2
+ import { registerNeoCmp } from 'neo-register';
3
+
4
+ registerNeoCmp(InfoCard, 'info-card');
@@ -0,0 +1,67 @@
1
+ .info-card-container {
2
+ position: relative;
3
+ box-sizing: border-box;
4
+ // border-bottom: 1px solid #ececec;
5
+ margin: 6px 12px;
6
+ padding: 6px 12px;
7
+ background-color: #fff;
8
+
9
+ .news-title {
10
+ padding: 6px 0;
11
+ font-family: PingFangSC-Regular;
12
+ font-size: 16px;
13
+ line-height: 22px;
14
+ color: #5f5e5e;
15
+ }
16
+
17
+ .item-imgbox {
18
+ position: relative;
19
+ height: 395px;
20
+ background: #f0f0f0;
21
+ cursor: pointer;
22
+ box-sizing: border-box;
23
+ text-align: center;
24
+ overflow: hidden;
25
+
26
+ .news-img {
27
+ width: 100%;
28
+ height: 100%;
29
+ box-sizing: border-box;
30
+ background-size: contain;
31
+ }
32
+
33
+ .img-count {
34
+ position: absolute;
35
+ top: 0;
36
+ right: 0;
37
+ padding: 6px 8px;
38
+ color: #fff;
39
+ min-width: 60px;
40
+ text-align: center;
41
+ line-height: 1.2;
42
+ background: rgba(0, 0, 0, 0.4);
43
+ font-size: 25px;
44
+ box-sizing: border-box;
45
+ overflow: hidden;
46
+ }
47
+ }
48
+
49
+ .news-info {
50
+ font-family: PingFangSC-Light;
51
+ height: 28px;
52
+ box-sizing: border-box;
53
+ display: flex;
54
+ justify-content: space-between;
55
+ align-items: center;
56
+ }
57
+
58
+ .media-mark,
59
+ .cmt-num {
60
+ display: inline-block;
61
+ height: 28px;
62
+ line-height: 28px;
63
+ font-family: PingFangSC-Light;
64
+ font-size: 18px;
65
+ color: #828282;
66
+ }
67
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import InfoCard from './components/info-card';
4
+
5
+ ReactDOM.render(<InfoCard />, document.getElementById('root'));
@@ -0,0 +1,10 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+ max_line_length = 80
@@ -0,0 +1,12 @@
1
+ /*
2
+ prettier 配置文件
3
+ 更多配置信息:https://prettier.io/docs/en/options.html
4
+ */
5
+ module.exports = {
6
+ semi: true, // Semicolons 分号,默认需要分号
7
+ tabWidth: 2, // 空格,默认 2,
8
+ useTabs: false,
9
+ singleQuote: true, // 单引号还是双引号,默认为false 双引号
10
+ trailingComma: 'all', // 逗号
11
+ jsxBracketSameLine: false, // 默认为false,Put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line (does not apply to self closing elements).
12
+ };
@@ -0,0 +1,53 @@
1
+ ### 目录说明
2
+ - src: 自定义组件源码;
3
+ - src/assets: 存放组件静态资源,比如 css、img等;
4
+ - src/components: 存放自定义组件代码,每个自定义组件以自身名称作为目录进行存放;
5
+ - src/components/info-card/index.tsx: 信息卡片自定义组件代码;
6
+ - src/components/info-card/register.ts: 用于注册一个 neo 自定义组件,注册成功后编辑器画布区中才会正常展示自定义组件内容;
7
+ - src/components/info-card/model.ts: 用于注册一个 neo-editor 自定义组件模型,注册成功后编辑器左侧组件面板中会展示;
8
+ - src/preview.tsx: 用于本地预览自定义组件内容;
9
+ - neo.config.js: neo-cmp-cli 配置文件。
10
+
11
+ ### 组件开发规范
12
+ - 存放在 src/components 目录下的自定义组件,默认 index 为自定义组件源码入口文件,register.[tj]s 为注册 Neo 组件的脚本文件,model.[tj]s 为自定义组件的描述文件(和页面设计器对接需要);
13
+ - 当 neo.config.js 中的 entry 为空或者不存在时,cli 将根据 src/components 目录下的自定义组件结构生成对应的 entry 配置(可在命令控制台查看生成的 entry 配置);
14
+ - 自定义组件中可用的配置项类型 请见 [当前可用表单项](https://github.com/wibetter/neo-register/blob/master/docs/FormItemType.md);
15
+ - 自定义组件最外层请设置一个唯一的 ClassName(比如 xx-cmpType-container),所有内容样式请放在该 ClassName 中;
16
+ - 默认开启代码规范检测(含样式内容),如需关闭,请调整 neo.config.js 相关配置。
17
+
18
+ ### 自定义组件注册器使用说明
19
+ - [neo-register 使用说明](https://www.npmjs.com/package/neo-register?activeTab=readme)
20
+
21
+ ### 开发说明
22
+
23
+ 1. **安装依赖**
24
+ ```bash
25
+ $ npm i 或者 yarn
26
+ ```
27
+
28
+ 2. **preview: 组件预览模式(带热更新)**
29
+ > preview模式:用于预览自定义组件内容。
30
+ ```bash
31
+ $ npm run preview
32
+ ```
33
+
34
+ 3. **linkDebug: 外链调试(在线上页面设计器端预览自定义组件)**
35
+ > linkDebug模式:用于在线上页面设计器中预览和调试自定义组件。
36
+ ```bash
37
+ $ npm run linkDebug
38
+ ```
39
+
40
+ 4. **build2lib: 构建自定义组件输出产物**
41
+ > build2lib模式:用于构建发布到 oss 中的文件,默认存放到 当前 dist 目录中。
42
+ ```bash
43
+ $ npm run build2lib
44
+ ```
45
+
46
+ 5. **发布到对象存储服务中**
47
+ > 需要确保 package.json 中的 name 值唯一,version 值不重复。
48
+ ```bash
49
+ $ npm run publish2oss
50
+ ```
51
+
52
+ ### 配置项说明(neo-cmp-cli)
53
+ [请查看neo-cmp-cli](https://github.com/wibetter/neo-cmp-cli)
@@ -0,0 +1,59 @@
1
+ /**
2
+ * https://www.npmjs.com/package/@commitlint/config-conventional\
3
+ *
4
+ * Git提交规范-配置文件
5
+ * Commit message 由Header、Body 和 Footer三个部分组成,其格式如下:
6
+ * <type>(<scope>): <subject>
7
+ * <BLANK LINE>
8
+ * <body>
9
+ * <BLANK LINE>
10
+ * <footer>
11
+ *
12
+ *【备注】
13
+ * type 用于说明 commit 的类别,常用下面 7 个标识:
14
+ * scope 用于说明当前功能点作用于哪个页面或者哪个功能模块;
15
+ * subject 用于简短的描述当前commit,不超过50个字符;
16
+ * body 用于填写对本次 commit 的详细描述,可以分成多行;
17
+ * footer 不兼容变动声明,或者关闭 Issue。
18
+ *
19
+ * 【type类型取值类型】
20
+ * feat:新功能(feature)
21
+ * fix:功能优化
22
+ * bug:修补bug
23
+ * docs:文档(documentation)
24
+ * style:格式(不影响代码运行的变动)
25
+ * refactor:重构(即不是新增功能,也不是修改bug的代码变动)
26
+ * test:增加测试
27
+ * chore:构建过程或辅助工具的变动
28
+ * build:影响构建系统或外部依赖项的更改(示例范围:gulp,broccoli,npm)
29
+ * ci:对 CI 配置文件和脚本的更改(示例范围:Travis,Circle,BrowserStack,SauceLabs)
30
+ * perf:改进性能的代码更改
31
+ *
32
+ */
33
+
34
+ module.exports = {
35
+ extends: ['@commitlint/config-conventional'],
36
+ rules: {
37
+ 'type-enum': [
38
+ 2,
39
+ 'always',
40
+ [
41
+ 'feat',
42
+ 'fix',
43
+ 'bug',
44
+ 'docs',
45
+ 'style',
46
+ 'refactor',
47
+ 'test',
48
+ 'chore',
49
+ 'perf',
50
+ 'build',
51
+ 'ci',
52
+ ],
53
+ ],
54
+ 'type-empty': [2, 'never'],
55
+ 'scope-empty': [1, 'never'],
56
+ 'subject-full-stop': [0, 'never'],
57
+ 'subject-case': [0, 'never'],
58
+ },
59
+ };
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+
4
+ // 统一路径解析
5
+ function resolve(dir) {
6
+ return path.resolve(__dirname, dir);
7
+ }
8
+
9
+ // 包括生产和开发的环境配置信息
10
+ module.exports = {
11
+ settings: {
12
+ enableESLint: true, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
13
+ enableESLintFix: true, // 是否自动修正代码格式,默认不自动修正
14
+ enableStyleLint: true, // 是否开启StyleLint,默认开启ESLint检测代码格式
15
+ enableStyleLintFix: true, // 是否需要StyleLint自动修正代码格式
16
+ },
17
+ webpack: {
18
+ resolve: {
19
+ // webpack的resolve配置
20
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
21
+ alias: {
22
+ '@': resolve('src'),
23
+ $assets: resolve('src/assets'),
24
+ $public: resolve('public'),
25
+ },
26
+ },
27
+ // sassResources中的sass文件会自动注入每一个sass文件中
28
+ sassResources: [
29
+ resolve('./src/assets/css/common.scss'),
30
+ resolve('./src/assets/css/mixin.scss'),
31
+ ],
32
+ // createDeclaration: true, // 打包时是否创建ts声明文件
33
+ ignoreNodeModules: false, // 打包时是否忽略 node_modules
34
+ allowList: [], // ignoreNodeModules为true时生效
35
+ projectDir: ['src'],
36
+ // template: resolve('./public/template.html'), // 自定义html模板
37
+ // plugins: []
38
+ },
39
+ preview: {
40
+ // 用于开启本地预览模式的相关配置信息
41
+ entry: {
42
+ // 本地预览自定义组件内容
43
+ index: './src/preview.tsx',
44
+ },
45
+ /*
46
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
47
+ NODE_ENV: 'development',
48
+ port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
49
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
50
+ assetsSubDirectory: '',
51
+ hostname: 'localhost',
52
+ proxyTable: {
53
+ '/apiTest': {
54
+ target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
55
+ ws: true,
56
+ changeOrigin: true,
57
+ },
58
+ },
59
+ */
60
+ },
61
+ linkDebug: {
62
+ // 用于开启本地调试模式的相关配置信息
63
+ /*
64
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
65
+ entry: { // entry 会根据 src/components 目录下的文件自动生成
66
+ // 外链调试(在线上页面设计器端预览自定义组件)
67
+ index: [
68
+ './src/components/info-card/register.ts',
69
+ './src/components/info-card/model.ts',
70
+ ],
71
+ },
72
+ NODE_ENV: 'development',
73
+ port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
74
+ assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
75
+ assetsSubDirectory: '',
76
+ hostname: 'localhost',
77
+ proxyTable: {
78
+ '/apiTest': {
79
+ target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
80
+ ws: true,
81
+ changeOrigin: true,
82
+ },
83
+ }
84
+ */
85
+ },
86
+ publish2oss: {
87
+ // 用于构建并发布至 OSS 的相关配置
88
+ /*
89
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
90
+ NODE_ENV: 'production',
91
+ entry: { // entry 未配置时,cli 会根据 src/components 目录下的文件自动生成对应的 entry
92
+ InfoCardModel: './src/components/info-card/model.ts',
93
+ infoCard: './src/components/info-card/register.ts'
94
+ },
95
+ cssExtract: false, // 不额外提取css文件
96
+ ossType: 'ali', // oss类型:ali、baidu
97
+ ossConfig: {
98
+ endpoint: 'https://oss-cn-beijing.aliyuncs.com',
99
+ AccessKeyId: 'xxx',
100
+ AccessKeySecret: 'xx',
101
+ bucket: 'neo-widgets' // 存储桶名称
102
+ },
103
+ assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
104
+ */
105
+ },
106
+ };