neo-cmp-cli 1.0.6 → 1.0.7
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.
- package/package.json +1 -1
- package/src/initData/neo.config.js +77 -68
- package/src/module/main.js +6 -2
- package/src/template/react-custom-cmp-template/package.json +1 -1
- package/src/template/react-ts-custom-cmp-template/neo.config.js +5 -26
- package/src/template/react-ts-custom-cmp-template/package.json +1 -1
- package/src/template/vue2-custom-cmp-template/package.json +1 -1
- package/src/utils/webpack.mf.js +4 -4
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
const path = require('path');
|
|
4
3
|
|
|
5
4
|
// 统一路径解析
|
|
@@ -10,90 +9,100 @@ function resolve(dir) {
|
|
|
10
9
|
// 包括生产和开发的环境配置信息
|
|
11
10
|
module.exports = {
|
|
12
11
|
settings: {
|
|
13
|
-
enableESLint:
|
|
14
|
-
enableESLintFix:
|
|
12
|
+
enableESLint: true, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
|
|
13
|
+
enableESLintFix: true, // 是否自动修正代码格式,默认不自动修正
|
|
15
14
|
enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
|
|
16
|
-
enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
|
|
15
|
+
enableStyleLintFix: false, // 是否需要StyleLint自动修正代码格式
|
|
17
16
|
},
|
|
18
17
|
webpack: {
|
|
19
|
-
|
|
20
|
-
// webpack构建入口(优先级低于于dev、build和build2lib中的entry配置)
|
|
21
|
-
index: './src/index.js'
|
|
22
|
-
},
|
|
18
|
+
target: ['web', 'es5'], // 指定目标环境为 web 和 es5,确保兼容性
|
|
23
19
|
resolve: {
|
|
24
20
|
// webpack的resolve配置
|
|
25
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.
|
|
21
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
|
|
26
22
|
alias: {
|
|
27
|
-
'@': resolve('src')
|
|
28
|
-
|
|
23
|
+
'@': resolve('src'),
|
|
24
|
+
$assets: resolve('src/assets'),
|
|
25
|
+
$public: resolve('public'),
|
|
26
|
+
},
|
|
29
27
|
},
|
|
30
|
-
|
|
28
|
+
// sassResources中的sass文件会自动注入每一个sass文件中
|
|
29
|
+
sassResources: [
|
|
30
|
+
resolve('./src/assets/css/common.scss'),
|
|
31
|
+
resolve('./src/assets/css/mixin.scss'),
|
|
32
|
+
],
|
|
33
|
+
// createDeclaration: true, // 打包时是否创建ts声明文件
|
|
31
34
|
ignoreNodeModules: false, // 打包时是否忽略 node_modules
|
|
32
35
|
allowList: [], // ignoreNodeModules为true时生效
|
|
33
|
-
externals: [], // 从输出的 bundle 中排除依赖
|
|
34
36
|
projectDir: ['src'],
|
|
35
|
-
|
|
37
|
+
// template: resolve('./public/template.html'), // 自定义html模板
|
|
38
|
+
plugins: [],
|
|
39
|
+
babelPlugins: [],
|
|
36
40
|
},
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
41
|
+
preview: {
|
|
42
|
+
// 用于开启本地预览模式的相关配置信息
|
|
43
|
+
entry: {
|
|
44
|
+
// 本地预览自定义组件内容
|
|
45
|
+
index: './src/preview.tsx',
|
|
42
46
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
/*
|
|
48
|
+
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
49
|
+
NODE_ENV: 'development',
|
|
50
|
+
port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
|
|
51
|
+
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
|
|
52
|
+
assetsSubDirectory: '',
|
|
53
|
+
hostname: 'localhost',
|
|
54
|
+
proxyTable: {
|
|
55
|
+
'/apiTest': {
|
|
56
|
+
target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
|
|
57
|
+
ws: true,
|
|
58
|
+
changeOrigin: true,
|
|
59
|
+
},
|
|
48
60
|
},
|
|
49
|
-
|
|
50
|
-
// 线上正式环境配置参数
|
|
51
|
-
'#dataApiBase#': '/', // 数据接口根地址 "//xxx.cn/"格式
|
|
52
|
-
'#assetsPublicPath#': '', // 静态资源根地址 "//xxx.cn/_spa/projectName"格式
|
|
53
|
-
'#routeBasePath#': '/' // 路由根地址 "/_spa/projectName/"格式
|
|
54
|
-
}
|
|
61
|
+
*/
|
|
55
62
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
linkDebug: {
|
|
64
|
+
// 用于开启本地调试模式的相关配置信息
|
|
65
|
+
/*
|
|
66
|
+
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
67
|
+
entry: { // entry 会根据 src/components 目录下的文件自动生成
|
|
68
|
+
// 外链调试(在线上页面设计器端预览自定义组件)
|
|
69
|
+
index: [
|
|
70
|
+
'./src/components/info-card/register.ts',
|
|
71
|
+
'./src/components/info-card/model.ts',
|
|
72
|
+
],
|
|
59
73
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
assetsRoot: resolve('dist'), // 编译完成的文件存放路径
|
|
74
|
+
NODE_ENV: 'development',
|
|
75
|
+
port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
|
|
63
76
|
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
|
|
64
|
-
assetsSubDirectory: '',
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// `npm run build --report`
|
|
75
|
-
// Set to `true` or `false` to always turn it on or off
|
|
76
|
-
bundleAnalyzerReport: false
|
|
77
|
+
assetsSubDirectory: '',
|
|
78
|
+
hostname: 'localhost',
|
|
79
|
+
proxyTable: {
|
|
80
|
+
'/apiTest': {
|
|
81
|
+
target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
|
|
82
|
+
ws: true,
|
|
83
|
+
changeOrigin: true,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
*/
|
|
77
87
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// 用于构建第三方功能包的配置文件
|
|
88
|
+
publish2oss: {
|
|
89
|
+
// 用于构建并发布至 OSS 的相关配置
|
|
90
|
+
/*
|
|
91
|
+
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
83
92
|
NODE_ENV: 'production',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
entry: { // entry 未配置时,cli 会根据 src/components 目录下的文件自动生成对应的 entry
|
|
94
|
+
InfoCardModel: './src/components/info-card/model.ts',
|
|
95
|
+
infoCard: './src/components/info-card/register.ts'
|
|
96
|
+
},
|
|
97
|
+
cssExtract: false, // 不额外提取css文件
|
|
98
|
+
ossType: 'ali', // oss类型:ali、baidu
|
|
99
|
+
ossConfig: {
|
|
100
|
+
endpoint: 'https://oss-cn-beijing.aliyuncs.com',
|
|
101
|
+
AccessKeyId: 'xxx',
|
|
102
|
+
AccessKeySecret: 'xx',
|
|
103
|
+
bucket: 'neo-widgets' // 存储桶名称
|
|
104
|
+
},
|
|
105
|
+
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
106
|
+
*/
|
|
94
107
|
},
|
|
95
|
-
build2esm: {
|
|
96
|
-
input: resolve('src/main.js'),
|
|
97
|
-
fileName: 'index'
|
|
98
|
-
}
|
|
99
108
|
};
|
package/src/module/main.js
CHANGED
|
@@ -59,7 +59,9 @@ module.exports = {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// 添加模块联邦插件
|
|
62
|
-
curConfig.
|
|
62
|
+
if (curConfig.dev.enableMF) {
|
|
63
|
+
curConfig.webpack.plugins.push(...MFPlugins);
|
|
64
|
+
}
|
|
63
65
|
|
|
64
66
|
akfun.dev(curConfig, consoleTag);
|
|
65
67
|
},
|
|
@@ -106,7 +108,9 @@ module.exports = {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
// 添加模块联邦插件
|
|
109
|
-
curConfig.
|
|
111
|
+
if (curConfig.publish2oss.enableMF) {
|
|
112
|
+
curConfig.webpack.plugins.push(...MFPlugins);
|
|
113
|
+
}
|
|
110
114
|
|
|
111
115
|
akfun.build('lib', curConfig, consoleTag, () => {
|
|
112
116
|
// 构建完成后,执行 publish2oss
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { ModuleFederationPlugin } = require('webpack').container;
|
|
4
|
-
const curDependencies = require('./package.json').dependencies;
|
|
5
3
|
|
|
6
4
|
// 统一路径解析
|
|
7
5
|
function resolve(dir) {
|
|
@@ -13,10 +11,11 @@ module.exports = {
|
|
|
13
11
|
settings: {
|
|
14
12
|
enableESLint: true, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
|
|
15
13
|
enableESLintFix: true, // 是否自动修正代码格式,默认不自动修正
|
|
16
|
-
enableStyleLint:
|
|
17
|
-
enableStyleLintFix:
|
|
14
|
+
enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
|
|
15
|
+
enableStyleLintFix: false, // 是否需要StyleLint自动修正代码格式
|
|
18
16
|
},
|
|
19
17
|
webpack: {
|
|
18
|
+
target: ['web', 'es5'], // 指定目标环境为 web 和 es5,确保兼容性
|
|
20
19
|
resolve: {
|
|
21
20
|
// webpack的resolve配置
|
|
22
21
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
|
|
@@ -36,28 +35,8 @@ module.exports = {
|
|
|
36
35
|
allowList: [], // ignoreNodeModules为true时生效
|
|
37
36
|
projectDir: ['src'],
|
|
38
37
|
// template: resolve('./public/template.html'), // 自定义html模板
|
|
39
|
-
plugins: [
|
|
40
|
-
|
|
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
|
+
plugins: [],
|
|
39
|
+
babelPlugins: [],
|
|
61
40
|
},
|
|
62
41
|
preview: {
|
|
63
42
|
// 用于开启本地预览模式的相关配置信息
|
package/src/utils/webpack.mf.js
CHANGED
|
@@ -43,13 +43,13 @@ const MFPlugins = [
|
|
|
43
43
|
}),
|
|
44
44
|
new ExternalTemplateRemotesPlugin(),
|
|
45
45
|
new webpack.NormalModuleReplacementPlugin(/(.*)/, (resource) => {
|
|
46
|
-
if ([
|
|
47
|
-
// 使用 Neo 提供的 react 和 react-dom
|
|
48
|
-
resource.request = `neoreact/${resource.request}`;
|
|
49
|
-
} else if (neoSharedDeps[resource.request]) {
|
|
46
|
+
if (neoSharedDeps[resource.request]) {
|
|
50
47
|
// 使用 Neo 提供的其他依赖
|
|
51
48
|
const mfKey = resource.request.replace(/(\/|\.)/gi, '_'); // 换成 neo-ui-mf-base exposes 的 key
|
|
52
49
|
resource.request = `neobase/${mfKey}`;
|
|
50
|
+
} else if (['react', 'react-dom'].indexOf(resource.request) > -1) {
|
|
51
|
+
// 使用 Neo 提供的 react 和 react-dom
|
|
52
|
+
resource.request = `neoreact/${resource.request}`;
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
55
|
];
|