@autobest-ui/scripts 1.5.8-alpha.0 → 1.5.9-alpha.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.
package/README.md CHANGED
@@ -51,49 +51,33 @@ module.exports = function(
51
51
  #### app.config.js 介绍
52
52
 
53
53
  ##### start 配置参数说明(作用于`react-spa start` 或者 `react-ssr start`)
54
- | 参数名 | 说明 |
55
- | ---- | ---- |
56
- | startEntry | start入口文件 |
57
- | startDefaultPort | start默认端口号, 可自定义,下面介绍 |
58
- | startOpenPath | start 打开浏览器的路径 |
59
- | startOutput.publicPath | start加载资源的路径 |
60
- | startOutput.path | start 资源根路径 |
61
- | getStartEnvConfig | start 自定义环境变量的方法,会追加到process.env中 |
54
+ | 参数名 | 默认值 | 说明 |
55
+ | ---- |------| ---- |
56
+ | startDefaultPort | 3030 | start默认端口号, 可自定义,下面介绍 |
57
+ | startOpenPath | '/' | start 打开浏览器的路径 |
58
+ | getStartEnvConfig | {} | start 自定义环境变量的方法,会追加到process.env中 |
62
59
 
63
60
  ##### hot ssr 配置参数说明(作用于`react-ssr ssr`)
64
- | 参数名 | 说明 |
65
- | ---- | ---- |
66
- | hotSsrClientEntry | hot ssr 客户端入口文件 |
67
- | hotSsrServerEntry | hot ssr 服务端入口文件 |
68
- | hotSsrDefaultPort | hot ssr默认端口号, 可自定义,下面介绍 |
69
- | hotSsrOpenPath | hot ssr 打开浏览器的路径 |
70
- | hotSsrRunPath | hot ssr 执行nodejs 入口文件路径 |
71
- | hotSsrWatch | hot ssr 需要watch的文件夹,类型: Array |
72
- | hotSsrClientOutput.publicPath | hot ssr客户端加载资源的路径 |
73
- | hotSsrClientOutput.path | hot ssr 客户端资源根路径 |
74
- | hotSsrServerOutput.publicPath | hot ssr 服务端加载资源的路径 |
75
- | hotSsrServerOutput.path | hot ssr 服务端资源根路径 |
76
- | getHotSsrEnvConfig | hot ssr 自定义环境变量的方法,会追加到process.env中 |
77
-
78
- ##### hot ssr 配置参数说明(作用于`react-ssr build`)
79
- | 参数名 | 说明 |
80
- | ---- | ---- |
81
- | buildClientEntry | build ssr 客户端入口文件 |
82
- | buildServerEntry | build ssr 客户端入口文件 |
83
- | buildClientOutput.publicPath | build ssr客户端加载资源的路径 |
84
- | buildClientOutput.path | build ssr 客户端资源根路径 |
85
- | buildServerOutput.publicPath | build ssr 服务端加载资源的路径 |
86
- | buildServerOutput.path | build ssr 服务端资源根路径 |
87
- | getBuildEnvConfig | build ssr 自定义环境变量的方法,会追加到process.env中 |
88
- | buildClientLoadableConfig.filename | build ssr 自定义按需加载路径存储库文件名 |
89
- | buildClientLoadableConfig.writeToDiskFilename | build ssr 自定义按需加载路径存储库文件存放位置 |
61
+ | 参数名 | 默认值 | 说明 |
62
+ | ---- |--------------------------------| ---- |
63
+ | hotSsrDefaultPort | 9090 | hot ssr默认端口号, 可自定义,下面介绍 |
64
+ | hotSsrOpenPath | '/' | hot ssr 打开浏览器的路径 |
65
+ | hotSsrRunPath | 'server/app.ts' | hot ssr 执行nodejs 入口文件路径 |
66
+ | hotSsrWatch |['devPublic', 'devBuild', 'server']| hot ssr 需要watch的文件夹,类型: Array |
67
+ | getHotSsrEnvConfig | {} | hot ssr 自定义环境变量的方法,会追加到process.env中 |
68
+
69
+ ##### build ssr 配置参数说明(作用于`react-ssr build`)
70
+ | 参数名 | 默认值 | 说明 |
71
+ | ---- |-----------------------| ---- |
72
+ | getBuildEnvConfig | {} | build ssr 自定义环境变量的方法,会追加到process.env中 |
73
+ | buildClientLoadableConfig.filename | 'loadable-stats.json' | build ssr 自定义按需加载路径存储库文件名 |
74
+ | buildClientLoadableConfig.writeToDiskFilename | '/build' | build ssr 自定义按需加载路径存储库文件存放位置 |
90
75
 
91
76
  ##### 公共配置
92
- | 参数名 | 说明 |
93
- |--------------------|------|
94
- | htmlPluginTemplate | client端,模板html路径 |
95
- | htmlPluginFavicon | client端,favicon.ico路径,也可以通过nginx配置 |
96
- | alias | debug, build 下文件别名,同webpack.resolve.alias一样 |
77
+ | 参数名 | 默认值 | 说明 |
78
+ |----------|---------------|------|
79
+ | htmlPluginTemplate | '/index.html' | client端,模板html路径 |
80
+ | htmlPluginFavicon | undefined | client端,favicon.ico路径,也可以通过nginx配置 |
97
81
 
98
82
  ## 自定义
99
83
 
@@ -18,10 +18,34 @@ const configPath = getProjectPath('/config/app.config.js');
18
18
 
19
19
  const config = require(configPath);
20
20
 
21
- module.exports = {
21
+ // 默认配置信息
22
+ const defaultConfig = {
22
23
  projectName: pkgInfo.name,
23
24
  projectVersion: pkgInfo.version,
25
+ // start默认配置
24
26
  startDefaultPort: 3030,
25
- startEntry: '/src/index.tsx',
27
+ startOpenPath: '/',
28
+ getStartEnvConfig: () => ({}),
29
+
30
+ // hot ssr默认配置
31
+ hotSsrDefaultPort: 9090,
32
+ hotSsrOpenPath: '/',
33
+ hotSsrRunPath: 'server/app.ts',
34
+ hotSsrWatch: ['devPublic', 'devBuild', 'server'],
35
+ getHotSsrEnvConfig: () => ({}),
36
+
37
+ // build默认配置
38
+ getBuildEnvConfig: () => ({}),
39
+ // build ssr默认配置
40
+ buildClientLoadableConfig: {
41
+ filename: 'loadable-stats.json',
42
+ writeToDiskFilename: '/build'
43
+ },
44
+ // html模板
45
+ htmlPluginTemplate: '/index.html'
46
+ };
47
+
48
+ module.exports = {
49
+ ...defaultConfig,
26
50
  ...config
27
51
  };
@@ -212,8 +212,6 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
212
212
  ]
213
213
  },
214
214
  resolve: {
215
- // 设置路径别名
216
- alias: appConfig.alias,
217
215
  // 文件后缀自动补全
218
216
  extensions: ['.tsx', '.ts', '.js', 'scss', 'css']
219
217
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobest-ui/scripts",
3
- "version": "1.5.8-alpha.0",
3
+ "version": "1.5.9-alpha.0",
4
4
  "private": false,
5
5
  "description": "utils for project tools",
6
6
  "bin": {
@@ -92,5 +92,5 @@
92
92
  "webpack-merge": "5.8.0",
93
93
  "webpack-node-externals": "3.0.0"
94
94
  },
95
- "gitHead": "1b1ba4a8f8af498939924fd6b6d09f84e41cbaf6"
95
+ "gitHead": "07a247ee99eeaa695b13bddf4051f7a433975115"
96
96
  }
@@ -8,10 +8,10 @@ const HOST = process.env.HOST || ip.address() || 'localhost';
8
8
 
9
9
  module.exports = function (appConfig, extendEnv) {
10
10
  return merge(baseConfig(false, appConfig, extendEnv), {
11
- entry: getProjectPath(appConfig.startEntry),
11
+ entry: getProjectPath('/src/index.tsx'),
12
12
  output: {
13
- publicPath: appConfig.startOutput.publicPath || '/',
14
- path: appConfig.startOutput.path,
13
+ publicPath: '/',
14
+ path: '/dist',
15
15
  pathinfo: true,
16
16
  filename: '[name].js',
17
17
  chunkFilename: '[name].chunk.js'
@@ -5,16 +5,13 @@ const { getProjectPath, deleteFolders } = require('../common/utils');
5
5
  const baseConfig = require('./webpack.base');
6
6
 
7
7
  module.exports = function (appConfig, extendEnv) {
8
- const outputPath = getProjectPath(appConfig.buildOutput.path);
9
- deleteFolders(outputPath);
10
-
11
- return merge(baseConfig(true, appConfig, extendEnv), {
8
+ const result = merge(baseConfig(true, appConfig, extendEnv), {
12
9
  // 打包的入口文件
13
- entry: getProjectPath(appConfig.buildEntry),
10
+ entry: getProjectPath('/src/index.tsx'),
14
11
  // 打包的出口
15
12
  output: {
16
- publicPath: appConfig.buildOutput.publicPath || '/',
17
- path: outputPath,
13
+ publicPath: '/',
14
+ path: '/build',
18
15
  // 入口文件生产的js
19
16
  filename: `js/[name].chunk.js?v=${extendEnv.version}`,
20
17
  // 非入口文件生产的js
@@ -80,4 +77,9 @@ module.exports = function (appConfig, extendEnv) {
80
77
  }
81
78
  }
82
79
  });
80
+
81
+ const outputPath = getProjectPath(result.output.path);
82
+ deleteFolders(outputPath);
83
+
84
+ return result;
83
85
  };
@@ -2,7 +2,6 @@ const webpack = require('webpack');
2
2
  const chalk = require('chalk');
3
3
  const appConfig = require('../common/appConfig');
4
4
  const { runCallback } = require('../common/build');
5
- const { getProjectPath, deleteFolders } = require('../common/utils');
6
5
  const getEnvironmentInfo = require('../common/extendEnv');
7
6
  const clientConfigFactory = require('./webpack.prod.client');
8
7
  const serverConfigFactory = require('./webpack.prod.server');
@@ -18,12 +17,6 @@ process.on('unhandledRejection', err => {
18
17
  const extendEnv = getEnvironmentInfo();
19
18
 
20
19
  function build() {
21
- const buildClientOutput = getProjectPath(appConfig.buildClientOutput.path);
22
- deleteFolders(buildClientOutput);
23
-
24
- const buildServerOutput = getProjectPath(appConfig.buildServerOutput.path);
25
- deleteFolders(buildServerOutput);
26
-
27
20
  const clientConfig = clientConfigFactory(appConfig, extendEnv);
28
21
  const serverConfig = serverConfigFactory(appConfig, extendEnv);
29
22
  // eslint-disable-next-line no-console
@@ -13,7 +13,7 @@ module.exports = (appConfig, extendEnv, { isServer, isHotServer, isProd }) => {
13
13
  result.plugins.push(
14
14
  new MiniCssExtractPlugin({
15
15
  // filename: isHotServer ? 'css/[name].css' : `css/[name].css?v=${env.version}`,
16
- // 采用AMP 直接 把css 填充到html
16
+ // 采用AMP直接把css填充到html
17
17
  filename: isHotServer ? 'css/[name].css' : 'css/[name][contenthash:8].css'
18
18
  })
19
19
  );
@@ -12,7 +12,7 @@ module.exports = function (appConfig, extendEnv) {
12
12
  }),
13
13
  {
14
14
  // 入口文件
15
- entry: getProjectPath(appConfig.hotSsrClientEntry),
15
+ entry: getProjectPath('/src/client-entry.tsx'),
16
16
  resolve: {
17
17
  fallback: {
18
18
  fs: false
@@ -21,8 +21,8 @@ module.exports = function (appConfig, extendEnv) {
21
21
  // 输出信息
22
22
  output: {
23
23
  // 输出文件路径
24
- path: getProjectPath(appConfig.hotSsrClientOutput.path),
25
- publicPath: appConfig.hotSsrClientOutput.publicPath || '/',
24
+ path: getProjectPath('/devPublic'),
25
+ publicPath: '/',
26
26
  filename: 'js/[name].js',
27
27
  chunkFilename: 'js/[name].js'
28
28
  },
@@ -15,10 +15,10 @@ module.exports = function (appConfig, extendEnv) {
15
15
  isProd: false
16
16
  }),
17
17
  {
18
- entry: getProjectPath(appConfig.startEntry),
18
+ entry: getProjectPath('/src/index.tsx'),
19
19
  output: {
20
- publicPath: appConfig.startOutput.publicPath || '/',
21
- path: appConfig.startOutput.path,
20
+ publicPath: '/',
21
+ path: '/dist',
22
22
  pathinfo: true,
23
23
  filename: '[name].js',
24
24
  chunkFilename: '[name].chunk.js'
@@ -20,11 +20,11 @@ module.exports = function (appConfig, extendEnv) {
20
20
  allowlist: /\.(js|css|less|scss|png|jpg|jpeg)$/
21
21
  }),
22
22
  // 入口文件
23
- entry: getProjectPath(appConfig.hotSsrServerEntry),
23
+ entry: getProjectPath('/src/serverEntry/index.tsx'),
24
24
  // 输出信息
25
25
  output: {
26
- path: getProjectPath(appConfig.hotSsrServerOutput.path),
27
- publicPath: appConfig.hotSsrServerOutput.publicPath || '/',
26
+ path: getProjectPath('/devBuild'),
27
+ publicPath: '/',
28
28
  // 输出文件名
29
29
  filename: 'bundle.js',
30
30
  libraryTarget: 'commonjs2'
@@ -2,22 +2,22 @@ const { merge } = require('webpack-merge');
2
2
  const LoadablePlugin = require('@loadable/webpack-plugin');
3
3
  const TerserPlugin = require('terser-webpack-plugin');
4
4
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
5
- const { getProjectPath } = require('../common/utils');
5
+ const { getProjectPath, deleteFolders } = require('../common/utils');
6
6
  const baseConfig = require('./webpack.base');
7
7
 
8
8
  module.exports = function (appConfig, extendEnv) {
9
- return merge(
9
+ const result = merge(
10
10
  baseConfig(appConfig, extendEnv, {
11
11
  isServer: false,
12
12
  isHotServer: false,
13
13
  isProd: true
14
14
  }),
15
15
  {
16
- entry: getProjectPath(appConfig.buildClientEntry),
16
+ entry: getProjectPath('/src/client-entry.tsx'),
17
17
  // 打包的出口
18
18
  output: {
19
- path: getProjectPath(appConfig.buildClientOutput.path),
20
- publicPath: appConfig.buildClientOutput.publicPath || '/',
19
+ path: getProjectPath('/build'),
20
+ publicPath: '/',
21
21
  // 入口文件生产的js
22
22
  filename: `js/[name].js?v=${extendEnv.version}`,
23
23
  // 非入口文件生产的js
@@ -91,4 +91,8 @@ module.exports = function (appConfig, extendEnv) {
91
91
  }
92
92
  }
93
93
  );
94
+
95
+ const buildClientOutput = getProjectPath(result.output.path);
96
+ deleteFolders(buildClientOutput);
97
+ return result;
94
98
  };
@@ -1,10 +1,10 @@
1
1
  const nodeExternals = require('webpack-node-externals');
2
2
  const { merge } = require('webpack-merge');
3
- const { getProjectPath } = require('../common/utils');
3
+ const { getProjectPath, deleteFolders } = require('../common/utils');
4
4
  const baseConfig = require('./webpack.base');
5
5
 
6
6
  module.exports = function (appConfig, extendEnv) {
7
- return merge(
7
+ const result = merge(
8
8
  baseConfig(appConfig, extendEnv, {
9
9
  isServer: true,
10
10
  isHotServer: false,
@@ -12,10 +12,10 @@ module.exports = function (appConfig, extendEnv) {
12
12
  }),
13
13
  {
14
14
  target: 'node',
15
- entry: getProjectPath(appConfig.buildServerEntry),
15
+ entry: getProjectPath('/src/serverEntry/index.tsx'),
16
16
  output: {
17
- path: getProjectPath(appConfig.buildServerOutput.path),
18
- publicPath: appConfig.buildServerOutput.publicPath || '/',
17
+ path: getProjectPath('/build'),
18
+ publicPath: '/',
19
19
  filename: 'server-bundle.js',
20
20
  libraryTarget: 'commonjs2',
21
21
  chunkFilename: 'js/[name].[chunkhash].js'
@@ -43,4 +43,9 @@ module.exports = function (appConfig, extendEnv) {
43
43
  })
44
44
  }
45
45
  );
46
+
47
+ const buildServerOutput = getProjectPath(result.output.path);
48
+ deleteFolders(buildServerOutput);
49
+
50
+ return result;
46
51
  };