akfun 5.0.1 → 5.0.3

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": "akfun",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -31,6 +31,7 @@ module.exports = function (fileName, akfunConfig) {
31
31
  const curConfig = akfunConfig || projectConfig;
32
32
  const build2esm = curConfig.build2esm || {};
33
33
  const curWebpackConfig = curConfig.webpack || {};
34
+ const buildType = build2esm.type || 'ts';
34
35
  // 获取用户配置的构建入口文件
35
36
  let rollupInput = resolveToCurrentRoot('src/main.js');
36
37
  if (build2esm.input) {
@@ -70,9 +71,10 @@ module.exports = function (fileName, akfunConfig) {
70
71
  nodeResolve({
71
72
  extensions: curConfig.webpack.resolve.extensions
72
73
  }),
73
- typescript(),
74
+ buildType === 'ts' ? typescript() : undefined,
74
75
  babel(babelConfig), // 备注,需要先babel()再commjs()
75
76
  // jsx( {factory: 'React.createElement'} ),
77
+ buildType === 'ts' ? jsx( {factory: 'React.createElement'} ) : undefined,
76
78
  vue(),
77
79
  commonjs(),
78
80
  postcss({
package/src/dev-server.js CHANGED
@@ -50,6 +50,23 @@ module.exports = function (akfunConfig, _consoleTag) {
50
50
  // 获取开发环境的webpack基本配置
51
51
  const webpackConfig = getDevWebpackConfig(config);
52
52
 
53
+ // Define HTTP proxies to your custom API backend
54
+ // https://github.com/chimurai/http-proxy-middleware
55
+ // 使用 config.dev.proxyTable 的配置作为 proxyTable 的代理配置
56
+ // 备注:需放connect-history-api-fallback前面,避免get请求的代理失效
57
+ const proxyTable = config.dev.proxyTable;
58
+ if (proxyTable && JSON.stringify(proxyTable) !== '{}') {
59
+ // 将 proxyTable 中的请求配置挂在到启动的 express 服务上
60
+ // proxy api requests
61
+ Object.keys(proxyTable).forEach((context) => {
62
+ let options = proxyTable[context];
63
+ if (typeof options === 'string') {
64
+ options = { target: options };
65
+ }
66
+ app.use(context, createProxyMiddleware(options));
67
+ });
68
+ }
69
+
53
70
  // 使用 connect-history-api-fallback 匹配资源,如果不匹配就可以重定向到指定地址
54
71
  // handle fallback for HTML5 history API
55
72
  // 备注:需放express.static前面,避免失效
@@ -81,22 +98,6 @@ module.exports = function (akfunConfig, _consoleTag) {
81
98
  // compilation error display
82
99
  app.use(hotMiddleware);
83
100
 
84
- // Define HTTP proxies to your custom API backend
85
- // https://github.com/chimurai/http-proxy-middleware
86
- // 使用 config.dev.proxyTable 的配置作为 proxyTable 的代理配置
87
- const proxyTable = config.dev.proxyTable;
88
- if (proxyTable && JSON.stringify(proxyTable) !== '{}') {
89
- // 将 proxyTable 中的请求配置挂在到启动的 express 服务上
90
- // proxy api requests
91
- Object.keys(proxyTable).forEach((context) => {
92
- let options = proxyTable[context];
93
- if (typeof options === 'string') {
94
- options = { target: options };
95
- }
96
- app.use(context, createProxyMiddleware(options));
97
- });
98
- }
99
-
100
101
  const afterCreateServerAction = (isHttps, port) => {
101
102
  spinner.succeed(`${consoleTag}调试模式已开启!`);
102
103
 
@@ -77,6 +77,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
77
77
  ? [
78
78
  nodeExternals({
79
79
  importType: 'commonjs',
80
+ additionalModuleDirs: curWebpackConfig.additionalModuleDirs || [],
80
81
  allowlist: curWebpackConfig.allowList ? curWebpackConfig.allowList : []
81
82
  })
82
83
  ].concat(curWebpackConfig.externals)
@@ -214,6 +215,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
214
215
  ? [
215
216
  nodeExternals({
216
217
  importType: 'commonjs',
218
+ additionalModuleDirs: curEnvConfig.additionalModuleDirs || curWebpackConfig.additionalModuleDirs || [],
217
219
  allowlist: allowList || []
218
220
  })
219
221
  ].concat(externals)