@autobest-ui/scripts 1.9.4 → 2.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.
package/README.md CHANGED
@@ -1,135 +1,4 @@
1
1
  # @autobest-ui/scripts
2
2
 
3
- ## 介绍
4
- 集成react项目在webpack下debug、build, 统一命令,方便维护与升级。
5
-
6
3
  ## 安装
7
- `npm install @autobest-ui/scripts --save-dev`
8
-
9
- ## 使用方式
10
-
11
- #### 单页面应用(SPA)
12
- 1. 本地 hot debug: `react-spa start`
13
-
14
- 2. build: `react-spa build`
15
-
16
- #### 服务端渲染应用(SSR)
17
- 1. 本地 client hot debug: `react-ssr start`
18
-
19
- 2. 本地 server hot debug: `react-ssr server`
20
-
21
- 3. build: `react-ssr build`
22
-
23
- ## 配置文件
24
- 根目录下创建`config`文件夹
25
-
26
- ```
27
- config
28
- app.config.js // 为命令提供的私有配置
29
- app.webpack.js // 扩展webpack配置, 非必须选
30
- env.js // 项目私有配置(比如: API BaseUrl配置),这个名字可以自定义
31
- ```
32
-
33
- #### app.webpack.js 介绍
34
-
35
- 该文件用于webpack扩展, 非必写。写法如下:
36
-
37
- ```
38
- module.exports = function(
39
- result,
40
- appConfig,
41
- extendEnv,
42
- { isProd, isServer, isHotServer }
43
- ) {
44
- // 根据条件,对不同环境的配置进行扩展
45
- ......
46
- // 最终返回扩展后的结果
47
- return result;
48
- }
49
- ```
50
-
51
- #### app.config.js 介绍
52
-
53
- ##### start 配置参数说明(作用于`react-spa start` 或者 `react-ssr start`)
54
- | 参数名 | 默认值 | 说明 |
55
- | ---- |------|-----------------------------------|
56
- | startDefaultPort | 3030 | start默认端口号, 可自定义,下面介绍 |
57
- | startOpenPath | '/' | start 打开浏览器的路径 |
58
- | getStartEnvConfig | {} | start 自定义环境变量的方法,会追加到process.env中 |
59
- | devServer | {} | start 自定义devServer配置 |
60
-
61
- ##### hot ssr 配置参数说明(作用于`react-ssr ssr`)
62
- | 参数名 | 默认值 | 说明 |
63
- | ---- |--------------------------------| ---- |
64
- | hotSsrDefaultPort | 9090 | hot ssr默认端口号, 可自定义,下面介绍 |
65
- | hotSsrOpenPath | '/' | hot ssr 打开浏览器的路径 |
66
- | hotSsrRunPath | 'server/app.ts' | hot ssr 执行nodejs 入口文件路径 |
67
- | hotSsrWatch |['devPublic', 'devBuild', 'server']| hot ssr 需要watch的文件夹,类型: Array |
68
- | getHotSsrEnvConfig | {} | hot ssr 自定义环境变量的方法,会追加到process.env中 |
69
-
70
- ##### build ssr 配置参数说明(作用于`react-ssr build`)
71
- | 参数名 | 默认值 | 说明 |
72
- | ---- |-----------------------| ---- |
73
- | getBuildEnvConfig | {} | build ssr 自定义环境变量的方法,会追加到process.env中 |
74
- | buildClientLoadableConfig.filename | 'loadable-stats.json' | build ssr 自定义按需加载路径存储库文件名 |
75
- | buildClientLoadableConfig.writeToDiskFilename | '/build' | build ssr 自定义按需加载路径存储库文件存放位置 |
76
-
77
- ##### 公共配置
78
- | 参数名 | 默认值 | 说明 |
79
- |----------|------|------|
80
- | htmlPluginTemplate | '/index.html' | client端,模板html路径 |
81
- | htmlPluginFavicon | undefined | client端,favicon.ico路径,也可以通过nginx配置 |
82
- | baseStaticMediaPath | static | 静态资源图片等基础文件夹 |
83
- | baseStaticCssPath | css | 静态资源css基础文件夹 |
84
- | baseStaticJsPath | js | 静态资源js基础文件夹 |
85
-
86
- ## 自定义
87
-
88
- #### 系统支持的运行参数
89
- | 参数名 | 默认值 | 说明 |
90
- |---------------------|-------------------|----------------------------------------------------------------|
91
- | --port 3031 | startDefaultPort值 | 覆盖默认端口号 `react-spa start --port 3031` |
92
- | --eslint | false | 运行时是否启动语法检查 `react-spa start --eslint`,`build`情况下该参数失效,不执行语法检查 |
93
-
94
- #### 自定义其他参数
95
- **例如:**
96
- - `react-spa start --site APW`
97
- - `react-ssr start --port 3032 --site APW`
98
-
99
- 该参数将解析成对象,通过get**EnvConfig()参数传递,此方式,可区分自定义的环境变量,例如:www2.0项目中site的区分。
100
-
101
-
102
- ### 自定义环境变量
103
- 该方式,主要应用于启动程序前,自定义环境变量,主要用于get**EnvConfig()方法的多样性。
104
-
105
- 例如: `cross-env REACT_APP_ENV=local react-ssr start`
106
-
107
- #### 背景图片问题
108
- 推荐把静态资源放到静态库,并使用sass环境变量`$env`进行本地调试,若想使用本地文件,需特殊处理。
109
-
110
- - scss环境变量
111
- ```scss
112
- // 其中 $env = process.env.NODE_ENV, 满足background-image链接不全、区分本地与线上样式等需求。
113
- if($env == 'development','为true的样式', ‘为false的样式’)
114
- // 例子
115
- $AssetBaseUrl: 'https://assets-web.dev.autobestdevops.com';
116
- $AssetCommonPath: '/common-uiasset';
117
- $AssetWwwPath: '/www-uiasset';
118
-
119
- @mixin getBgImgFromCommon($url) {
120
- background-image: if($env == 'development', url($AssetBaseUrl + $AssetCommonPath + $url), url($AssetCommonPath + $url));
121
- }
122
-
123
- @mixin getBgImgFromWww($url) {
124
- background-image: if($env == 'development', url($AssetBaseUrl + $AssetWwwPath + $url), url($AssetWwwPath + $url));
125
- }
126
- ```
127
-
128
- - 使用本地文件注意事项
129
- ```scss
130
- // background image 不解析以"http、https"开头或者/common-uiasset/|/wwwasset/|/onlineasset/开头的静态资源, 例如:'/common-uiasset/img.png'
131
- // 所以本地静态资源需要特别注意,不能创建/common-uiasset/|/wwwasset/|/onlineasset/文件夹
132
- .live-chat {
133
- background: url('imgs/图片名.resolving.png') 0 center no-repeat;
134
- }
135
- ```
4
+ `npm install @autobest-ui/scripts --save-dev`
@@ -0,0 +1,64 @@
1
+ const webpack = require('webpack');
2
+ const chalk = require('chalk');
3
+ const appConfig = require('../common/appConfig');
4
+ const { runCallback } = require('../common/build');
5
+ const getEnvironmentInfo = require('../common/extendEnv');
6
+ const extendWebpackConfigFromProject = require('../common/extendWebpackConfigFromProject');
7
+ const apiConfigFactory = require('./webpack.prod.api');
8
+
9
+ process.env.BABEL_ENV = 'production';
10
+ process.env.NODE_ENV = 'production';
11
+
12
+ process.on('unhandledRejection', err => {
13
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
14
+ throw err;
15
+ });
16
+
17
+ const extendEnv = getEnvironmentInfo();
18
+
19
+ function build() {
20
+ const apiConfig = extendWebpackConfigFromProject(apiConfigFactory, appConfig, extendEnv, {
21
+ isServer: true,
22
+ isHotServer: false,
23
+ isProd: true
24
+ });
25
+ // eslint-disable-next-line no-console
26
+ console.log(chalk.green('Creating an optimized production build...'));
27
+ const apiCompiler = webpack(apiConfig);
28
+ return new Promise((resolve, reject) => {
29
+ apiCompiler.run(runCallback(resolve, reject));
30
+ });
31
+ }
32
+
33
+ build()
34
+ .then(
35
+ buildInfo => {
36
+ if (buildInfo.warnings.length) {
37
+ // eslint-disable-next-line no-console
38
+ console.log(chalk.yellow('Compiled with warnings.\n'));
39
+ // eslint-disable-next-line no-console
40
+ console.log(buildInfo.warnings.join('\n\n'));
41
+ // eslint-disable-next-line no-console
42
+ console.log(`\nSearch for the ${chalk.underline(chalk.yellow('keywords'))} to learn more about each warning.`);
43
+ // eslint-disable-next-line no-console
44
+ console.log(`To ignore, add ${chalk.cyan('// eslint-disable-next-line')} to the line before.\n`);
45
+ } else {
46
+ // eslint-disable-next-line no-console
47
+ console.log(chalk.green('Compiled successfully.\n'));
48
+ }
49
+ },
50
+ err => {
51
+ // eslint-disable-next-line no-console
52
+ console.log(chalk.red('Failed to compile.\n'));
53
+ // eslint-disable-next-line no-console
54
+ console.log(err);
55
+ process.exit(1);
56
+ }
57
+ )
58
+ .catch(err => {
59
+ // eslint-disable-next-line no-console
60
+ console.log(chalk.red('Failed to compile.\n'));
61
+ // eslint-disable-next-line no-console
62
+ console.log(err);
63
+ process.exit(1);
64
+ });
@@ -0,0 +1,54 @@
1
+ const nodemon = require('nodemon');
2
+ const open = require('open');
3
+ const getEnvironmentInfo = require('../common/extendEnv');
4
+ const appConfig = require('../common/appConfig');
5
+ const { getProjectPath, parseArgsToJson } = require('../common/utils');
6
+
7
+ const extendEnv = getEnvironmentInfo();
8
+
9
+ const PORT = process.env.PORT || parseArgsToJson.port || appConfig.startDefaultPort;
10
+ const startOpenPath = appConfig.startOpenPath ? appConfig.startOpenPath : '';
11
+
12
+ process.env.BABEL_ENV = 'development';
13
+ process.env.NODE_ENV = 'development';
14
+
15
+ const options = {
16
+ // 配置文件
17
+ script: getProjectPath(appConfig.apiEntry),
18
+ restartable: 're',
19
+ verbose: true,
20
+ delay: 1000,
21
+ watch: appConfig.hotApiWatch,
22
+ env: {
23
+ PORT: PORT,
24
+ BABEL_ENV: 'development',
25
+ NODE_ENV: 'development',
26
+ ...extendEnv.raw
27
+ }
28
+ };
29
+
30
+ let isOpened = false;
31
+
32
+ nodemon(options)
33
+ .on('start', () => {
34
+ // 启动时的事件
35
+ // eslint-disable-next-line no-console
36
+ console.log('Server app has started');
37
+ if (startOpenPath && !isOpened) {
38
+ setTimeout(() => {
39
+ open(`http://localhost:${PORT}${startOpenPath}`);
40
+ }, 3000);
41
+ isOpened = true;
42
+ }
43
+ })
44
+ .on('quit', () => {
45
+ // 退出时的事件
46
+ // eslint-disable-next-line no-console
47
+ console.log('Server app has quit');
48
+ process.exit();
49
+ })
50
+ .on('restart', () => {
51
+ // 重启时的事件
52
+ // eslint-disable-next-line no-console
53
+ console.log('Server app has restarted');
54
+ });
@@ -0,0 +1,38 @@
1
+ const { merge } = require('webpack-merge');
2
+ const { getProjectPath, deleteFolders } = require('../common/utils');
3
+ const webpackCommon = require('../common/webpack.common');
4
+
5
+ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd }) {
6
+ const result = merge(webpackCommon(appConfig, extendEnv, { isProd, isServer, isHotServer }), {
7
+ target: 'node',
8
+ entry: getProjectPath(appConfig.apiEntry),
9
+ output: {
10
+ path: getProjectPath(appConfig.apiOutputPath),
11
+ publicPath: '/',
12
+ filename: 'index.js',
13
+ libraryTarget: 'commonjs2',
14
+ chunkFilename: '[name].[chunkhash].js'
15
+ },
16
+ module: {
17
+ rules: [
18
+ {
19
+ oneOf: [
20
+ {
21
+ test: /\.(scss|css|sass)$/,
22
+ use: [
23
+ {
24
+ loader: require.resolve('ignore-loader')
25
+ }
26
+ ]
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ });
33
+
34
+ const buildServerOutput = getProjectPath(result.output.path);
35
+ deleteFolders(buildServerOutput);
36
+
37
+ return result;
38
+ };
package/bin/api.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.on('unhandledRejection', err => {
4
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
5
+ throw err;
6
+ });
7
+
8
+ const spawn = require('cross-spawn');
9
+
10
+ const args = process.argv.slice(2);
11
+
12
+ const scriptIndex = args.findIndex(x => x === 'build' || x === 'start');
13
+ const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
14
+ const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
15
+
16
+ if (['build', 'start'].includes(script)) {
17
+ const result = spawn.sync(
18
+ process.execPath,
19
+ nodeArgs.concat(require.resolve(`../apiConfig/${script}`)).concat(args.slice(scriptIndex + 1)),
20
+ { stdio: 'inherit' }
21
+ );
22
+ if (result.signal) {
23
+ if (result.signal === 'SIGKILL') {
24
+ // eslint-disable-next-line no-console
25
+ console.log(
26
+ 'The build failed because the process exited too early. ' +
27
+ 'This probably means the system ran out of memory or someone called ' +
28
+ '`kill -9` on the process.'
29
+ );
30
+ } else if (result.signal === 'SIGTERM') {
31
+ // eslint-disable-next-line no-console
32
+ console.log(
33
+ 'The build failed because the process exited too early. ' +
34
+ 'Someone might have called `kill` or `killall`, or the system could ' +
35
+ 'be shutting down.'
36
+ );
37
+ }
38
+ process.exit(1);
39
+ }
40
+ process.exit(result.status);
41
+ } else {
42
+ // eslint-disable-next-line no-console
43
+ console.log(`Unknown script "${script}".`);
44
+ }
package/bin/spa.js CHANGED
File without changes
package/bin/ssr.js CHANGED
@@ -9,7 +9,7 @@ const spawn = require('cross-spawn');
9
9
 
10
10
  const args = process.argv.slice(2);
11
11
 
12
- const scriptIndex = args.findIndex(x => x === 'build' || x === 'start' || 'server');
12
+ const scriptIndex = args.findIndex(x => x === 'build' || x === 'start' || x === 'server');
13
13
  const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
14
14
  const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
15
15
 
@@ -28,11 +28,20 @@ const defaultConfig = {
28
28
  getStartEnvConfig: () => ({}),
29
29
  devServer: {},
30
30
 
31
+ clientEntryAtSpa: '/src/index.tsx',
32
+ clientOutputPathAtSpa: '/build',
33
+
34
+ clientEntryAtSsr: '/src/client-entry.tsx',
35
+ clientOutputPathAtSsr: '/build',
36
+
37
+ serverEntryAtSsr: '/server/index.ts',
38
+ serverOutputPathAtSsr: '/dist',
39
+
31
40
  // hot ssr默认配置
32
41
  hotSsrDefaultPort: 9090,
33
42
  hotSsrOpenPath: '/',
34
- hotSsrRunPath: 'server/app.ts',
35
- hotSsrWatch: ['devPublic', 'devBuild', 'server'],
43
+ hotSsrRunPath: '/dist/index.js',
44
+ hotSsrWatch: ['build', 'dist'],
36
45
  getHotSsrEnvConfig: () => ({}),
37
46
 
38
47
  // build默认配置
@@ -49,7 +58,12 @@ const defaultConfig = {
49
58
  // 静态资源css基础文件夹
50
59
  baseStaticCssPath: 'css',
51
60
  // 静态资源js基础文件夹
52
- baseStaticJsPath: 'js'
61
+ baseStaticJsPath: 'js',
62
+
63
+ // API 配置
64
+ apiEntry: '/src/index.ts',
65
+ apiOutputPath: '/build',
66
+ hotApiWatch: ['src']
53
67
  };
54
68
 
55
69
  module.exports = {
@@ -213,7 +213,6 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
213
213
  extensions: ['.tsx', '.ts', '.js', 'scss', 'css']
214
214
  },
215
215
  plugins: [
216
- new webpack.DefinePlugin(extendEnv.stringified),
217
216
  new ProgressBarPlugin({
218
217
  // eslint-disable-next-line no-useless-concat
219
218
  format: 'build [:bar] ' + ':percent' + ' (:elapsed seconds)',
@@ -243,6 +242,10 @@ module.exports = (appConfig, extendEnv, { isProd, isServer, isHotServer }) => {
243
242
  );
244
243
  }
245
244
 
245
+ if (!isServer) {
246
+ result.plugins.push(new webpack.DefinePlugin(extendEnv.stringified));
247
+ }
248
+
246
249
  if (isProd && !isServer) {
247
250
  result.optimization = {
248
251
  chunkIds: 'named',
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@autobest-ui/scripts",
3
- "version": "1.9.4",
3
+ "version": "2.0.0",
4
4
  "private": false,
5
5
  "description": "utils for project tools",
6
6
  "bin": {
7
7
  "react-spa": "./bin/spa.js",
8
- "react-ssr": "./bin/ssr.js"
8
+ "react-ssr": "./bin/ssr.js",
9
+ "node-api": "./bin/api.js"
9
10
  },
10
11
  "scripts": {
11
12
  "clean": "rimraf lib esm",
@@ -21,6 +22,7 @@
21
22
  "bin",
22
23
  "spaConfig",
23
24
  "ssrConfig",
25
+ "apiConfig",
24
26
  "common"
25
27
  ],
26
28
  "keywords": [
@@ -62,7 +64,7 @@
62
64
  "@babel/preset-react": "7.18.6",
63
65
  "@babel/preset-typescript": "7.18.6",
64
66
  "@babel/runtime": "7.20.1",
65
- "@loadable/babel-plugin": "5.15.3",
67
+ "@loadable/babel-plugin": "5.13.2",
66
68
  "@loadable/webpack-plugin": "5.15.2",
67
69
  "@soda/friendly-errors-webpack-plugin": "1.8.1",
68
70
  "babel-loader": "8.2.4",
@@ -98,9 +100,5 @@
98
100
  "webpack-merge": "5.8.0",
99
101
  "webpack-node-externals": "3.0.0"
100
102
  },
101
- "peerDependencies": {
102
- "eslint": "^8.23.1",
103
- "typescript": "4.8.3"
104
- },
105
- "gitHead": "2611548b4427c16fb03f9437ab20889615441a95"
103
+ "gitHead": "fb75bd54150164e95c075eef437badba8dcd0728"
106
104
  }
@@ -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('/src/index.tsx'),
11
+ entry: getProjectPath(appConfig.clientEntryAtSpa),
12
12
  output: {
13
13
  publicPath: '/',
14
- path: getProjectPath('/dist'),
14
+ path: getProjectPath(appConfig.clientOutputPathAtSpa),
15
15
  pathinfo: true,
16
16
  filename: '[name].js',
17
17
  chunkFilename: '[name].chunk.js'
@@ -7,11 +7,11 @@ const baseConfig = require('./webpack.base');
7
7
  module.exports = function (appConfig, extendEnv) {
8
8
  const result = merge(baseConfig(true, appConfig, extendEnv), {
9
9
  // 打包的入口文件
10
- entry: getProjectPath('/src/index.tsx'),
10
+ entry: getProjectPath(appConfig.clientEntryAtSpa),
11
11
  // 打包的出口
12
12
  output: {
13
13
  publicPath: '/',
14
- path: getProjectPath('/build'),
14
+ path: getProjectPath(appConfig.clientOutputPathAtSpa),
15
15
  // 入口文件生产的js
16
16
  filename: `${appConfig.baseStaticJsPath}/[name].chunk.js?v=${extendEnv.version}`,
17
17
  // 非入口文件生产的js
@@ -12,7 +12,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
12
12
  }),
13
13
  {
14
14
  // 入口文件
15
- entry: getProjectPath('/src/client-entry.tsx'),
15
+ entry: getProjectPath(appConfig.clientEntryAtSsr),
16
16
  resolve: {
17
17
  fallback: {
18
18
  fs: false
@@ -21,7 +21,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
21
21
  // 输出信息
22
22
  output: {
23
23
  // 输出文件路径
24
- path: getProjectPath('/devPublic'),
24
+ path: getProjectPath(appConfig.clientOutputPathAtSsr),
25
25
  publicPath: '/',
26
26
  filename: `${appConfig.baseStaticJsPath}/[name].js`,
27
27
  chunkFilename: `${appConfig.baseStaticJsPath}/[name].js`
@@ -15,10 +15,10 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
15
15
  isProd
16
16
  }),
17
17
  {
18
- entry: getProjectPath('/src/index.tsx'),
18
+ entry: getProjectPath(appConfig.clientEntryAtSpa),
19
19
  output: {
20
20
  publicPath: '/',
21
- path: getProjectPath('/dist'),
21
+ path: getProjectPath(appConfig.clientOutputPathAtSpa),
22
22
  pathinfo: true,
23
23
  filename: '[name].js',
24
24
  chunkFilename: '[name].chunk.js'
@@ -20,13 +20,13 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
20
20
  allowlist: /\.(js|css|less|scss|png|jpg|jpeg)$/
21
21
  }),
22
22
  // 入口文件
23
- entry: getProjectPath('/src/serverEntry/index.tsx'),
23
+ entry: getProjectPath(appConfig.serverEntryAtSsr),
24
24
  // 输出信息
25
25
  output: {
26
- path: getProjectPath('/devBuild'),
26
+ path: getProjectPath(appConfig.serverOutputPathAtSsr),
27
27
  publicPath: '/',
28
28
  // 输出文件名
29
- filename: 'bundle.js',
29
+ filename: 'index.js',
30
30
  libraryTarget: 'commonjs2'
31
31
  },
32
32
  module: {
@@ -13,10 +13,10 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
13
13
  isProd
14
14
  }),
15
15
  {
16
- entry: getProjectPath('/src/client-entry.tsx'),
16
+ entry: getProjectPath(appConfig.clientEntryAtSsr),
17
17
  // 打包的出口
18
18
  output: {
19
- path: getProjectPath('/build'),
19
+ path: getProjectPath(appConfig.clientOutputPathAtSsr),
20
20
  publicPath: '/',
21
21
  // 入口文件生产的js
22
22
  filename: `${appConfig.baseStaticJsPath}/[name].js?v=${extendEnv.version}`,
@@ -1,4 +1,3 @@
1
- const nodeExternals = require('webpack-node-externals');
2
1
  const { merge } = require('webpack-merge');
3
2
  const { getProjectPath, deleteFolders } = require('../common/utils');
4
3
  const baseConfig = require('./webpack.base');
@@ -12,11 +11,11 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
12
11
  }),
13
12
  {
14
13
  target: 'node',
15
- entry: getProjectPath('/src/serverEntry/index.tsx'),
14
+ entry: getProjectPath(appConfig.serverEntryAtSsr),
16
15
  output: {
17
- path: getProjectPath('/build'),
16
+ path: getProjectPath(appConfig.serverOutputPathAtSsr),
18
17
  publicPath: '/',
19
- filename: 'server-bundle.js',
18
+ filename: 'index.js',
20
19
  libraryTarget: 'commonjs2',
21
20
  chunkFilename: `${appConfig.baseStaticJsPath}/[name].[chunkhash].js`
22
21
  },
@@ -35,12 +34,7 @@ module.exports = function (appConfig, extendEnv, { isServer, isHotServer, isProd
35
34
  ]
36
35
  }
37
36
  ]
38
- },
39
- // 服务端打包的时候忽略外部的npm包
40
- externals: nodeExternals({
41
- // 当然外部的css还是可以打进来的
42
- allowlist: /\.(css|less|scss)$/
43
- })
37
+ }
44
38
  }
45
39
  );
46
40