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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -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: false, // 调试模式是否开启ESLint,默认关闭ESLint检测代码格式
14
- enableESLintFix: false, // 是否自动修正代码格式,默认不自动修正
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
- entry: {
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', '.vue', '.min.js', 'json'], // 用于配置webpack在尝试过程中用到的后缀列表
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
- createDeclaration: false, // 打包时是否创建ts声明文件
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
- sassResources: []
37
+ // template: resolve('./public/template.html'), // 自定义html模板
38
+ plugins: [],
39
+ babelPlugins: [],
36
40
  },
37
- envParams: {
38
- // 项目系统环境变量
39
- common: {
40
- // 通用参数
41
- '#version#': '20200810.1'
41
+ preview: {
42
+ // 用于开启本地预览模式的相关配置信息
43
+ entry: {
44
+ // 本地预览自定义组件内容
45
+ index: './src/preview.tsx',
42
46
  },
43
- local: {
44
- // 本地开发环境
45
- '#dataApiBase#': 'http://localhost:1024', // 数据接口根地址
46
- '#assetsPublicPath#': 'http://localhost:1024', // 静态资源根地址
47
- '#routeBasePath#': '/' // 路由根地址
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
- online: {
50
- // 线上正式环境配置参数
51
- '#dataApiBase#': '/', // 数据接口根地址 "//xxx.cn/"格式
52
- '#assetsPublicPath#': '', // 静态资源根地址 "//xxx.cn/_spa/projectName"格式
53
- '#routeBasePath#': '/' // 路由根地址 "/_spa/projectName/"格式
54
- }
61
+ */
55
62
  },
56
- build: {
57
- entry: {
58
- index: './src/index.js'
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
- NODE_ENV: 'production', // production 模式,会启动UglifyJsPlugin服务
62
- assetsRoot: resolve('dist'), // 编译完成的文件存放路径
74
+ NODE_ENV: 'development',
75
+ port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
63
76
  assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
64
- assetsSubDirectory: '', // 资源引用二级路径
65
- productionSourceMap: false,
66
- // Gzip off by default as many popular public hosts such as
67
- // Surge or Netlify already gzip all public assets for you.
68
- // Before setting to `true`, make sure to:
69
- // npm install --save-dev compression-webpack-plugin
70
- productionGzip: false,
71
- productionGzipExtensions: ['js', 'css', 'json'],
72
- // Run the build command with an extra argument to
73
- // View the bundle analyzer report after build finishes:
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
- build2lib: {
79
- entry: {
80
- index: './src/index.js'
81
- },
82
- // 用于构建第三方功能包的配置文件
88
+ publish2oss: {
89
+ // 用于构建并发布至 OSS 的相关配置
90
+ /*
91
+ 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
83
92
  NODE_ENV: 'production',
84
- libraryName: '', // 构建第三方功能包时最后导出的引用变量名
85
- assetsRoot: resolve('dist'), // 编译完成的文件存放路径
86
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
87
- assetsSubDirectory: '', // 资源引用二级路径
88
- ignoreNodeModules: true, // 打包时是否忽略 node_modules
89
- allowList: [], // ignoreNodeModules为true时生效
90
- productionSourceMap: false,
91
- productionGzip: false,
92
- productionGzipExtensions: ['js', 'css', 'json'],
93
- bundleAnalyzerReport: false
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
  };
@@ -59,7 +59,9 @@ module.exports = {
59
59
  }
60
60
 
61
61
  // 添加模块联邦插件
62
- curConfig.webpack.plugins.push(...MFPlugins);
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.webpack.plugins.push(...MFPlugins);
111
+ if (curConfig.publish2oss.enableMF) {
112
+ curConfig.webpack.plugins.push(...MFPlugins);
113
+ }
110
114
 
111
115
  akfun.build('lib', curConfig, consoleTag, () => {
112
116
  // 构建完成后,执行 publish2oss
@@ -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.3",
47
+ "neo-cmp-cli": "^1.0.7",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5"
@@ -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: true, // 是否开启StyleLint,默认开启ESLint检测代码格式
17
- enableStyleLintFix: true, // 是否需要StyleLint自动修正代码格式
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
- 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
+ plugins: [],
39
+ babelPlugins: [],
61
40
  },
62
41
  preview: {
63
42
  // 用于开启本地预览模式的相关配置信息
@@ -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.5",
50
+ "neo-cmp-cli": "^1.0.7",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -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.3",
47
+ "neo-cmp-cli": "^1.0.7",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5",
@@ -43,13 +43,13 @@ const MFPlugins = [
43
43
  }),
44
44
  new ExternalTemplateRemotesPlugin(),
45
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]) {
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
  ];