akfun 1.5.15 → 1.5.16

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
@@ -270,7 +270,19 @@ module.exports = {
270
270
  }
271
271
  ```
272
272
 
273
- 9. 项目源码环境变量批量替换
273
+ 9. 配置项目源码目录(工程有效目录范围): projectDir
274
+ > 构建项目中,设置生效的目录(可同时设置多个目录),用于提高前端工程执行效率。可以不配置,默认为['./src']
275
+ ```bash
276
+ module.exports = {
277
+ ...
278
+ webpack: {
279
+ projectDir: ['./src'],
280
+ }
281
+ ...
282
+ }
283
+ ```
284
+
285
+ 10. 项目源码环境变量批量替换
274
286
  > [关于params-replace-loader的使用方法](https://www.npmjs.com/package/params-replace-loader)
275
287
  ```bash
276
288
  module.exports = {
@@ -289,7 +301,7 @@ module.exports = {
289
301
  }
290
302
  ```
291
303
 
292
- 10. 接口代理配置:目前只有dev本地开发调试模式下会启动
304
+ 11. 接口代理配置:目前只有dev本地开发调试模式下会启动
293
305
  > [关于proxyTable的配置方法](https://www.webpackjs.com/configuration/dev-server/#devserver-proxy)
294
306
  ```bash
295
307
  module.exports = {
@@ -302,7 +314,7 @@ module.exports = {
302
314
  }
303
315
  ```
304
316
 
305
- 11. 用于开启本地调试模式的相关配置信息
317
+ 12. 用于开启本地调试模式的相关配置信息
306
318
  ```bash
307
319
  module.exports = {
308
320
  ...
@@ -326,7 +338,7 @@ module.exports = {
326
338
  }
327
339
  ```
328
340
 
329
- 12. 用于构建生产环境代码的相关配置信息
341
+ 13. 用于构建生产环境代码的相关配置信息
330
342
  ```bash
331
343
  module.exports = {
332
344
  ...
@@ -344,7 +356,7 @@ module.exports = {
344
356
  }
345
357
  ```
346
358
 
347
- 13. 用于构建第三方功能包的配置(以umd格式输出)
359
+ 14. 用于构建第三方功能包的配置(以umd格式输出)
348
360
  ```bash
349
361
  module.exports = {
350
362
  ...
@@ -363,7 +375,7 @@ module.exports = {
363
375
  }
364
376
  ```
365
377
 
366
- 14. 用于构建esm格式的第三方功能包配置
378
+ 15. 用于构建esm格式的第三方功能包配置
367
379
  ```bash
368
380
  module.exports = {
369
381
  ...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "1.5.15",
3
+ "version": "1.5.16",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
@@ -0,0 +1,16 @@
1
+ const { resolveToCurrentRoot } = require('./pathUtils');
2
+ const { isArray, isString } = require('../utils/typeof');
3
+
4
+ module.exports = (_projectDir) => {
5
+ const curProjectDir = [];
6
+ if (!_projectDir) {
7
+ curProjectDir.push(resolveToCurrentRoot('./src'));
8
+ } else if (isArray(_projectDir)) {
9
+ _projectDir.forEach((dir) => {
10
+ curProjectDir.push(resolveToCurrentRoot(dir));
11
+ });
12
+ } else if (isString(_projectDir)) {
13
+ curProjectDir.push(resolveToCurrentRoot(_projectDir));
14
+ }
15
+ return curProjectDir;
16
+ };
@@ -7,6 +7,7 @@ const utils = require('./loaderUtils');
7
7
  const vueLoaderConfig = require('./vue-loader.conf');
8
8
  const { resolve, resolveToCurrentRoot, catchCurPackageJson } = require('../utils/pathUtils');
9
9
  const getConfigObj = require('../utils/getConfigObj');
10
+ const getProjectDir = require('../utils/getProjectDir');
10
11
  const catchVuePages = require('../utils/catchVuePages'); // 用于获取当前项目中的vue单文件
11
12
  // 引入当前项目配置文件
12
13
  const config = require('../config/index');
@@ -34,6 +35,8 @@ const BannerPack = new webpack.BannerPlugin({
34
35
  */
35
36
  module.exports = (option) => {
36
37
  const curEnvConfig = option || {}; // 用于接收当前运行环境配置变量
38
+ // 获取当前项目目录
39
+ const curProjectDir = getProjectDir(config.webpack.projectDir);
37
40
  const webpackConfig = {
38
41
  entry: config.webpack.entry,
39
42
  /*
@@ -81,7 +84,7 @@ module.exports = (option) => {
81
84
  }
82
85
  }
83
86
  ],
84
- include: [resolve('src')],
87
+ include: curProjectDir, // [resolve('src')],
85
88
  exclude: /node_modules/
86
89
  },
87
90
  {
@@ -92,7 +95,7 @@ module.exports = (option) => {
92
95
  options: babelConfig
93
96
  }
94
97
  ],
95
- include: [resolve('src')],
98
+ include: curProjectDir, // [resolve('src')],
96
99
  exclude: /node_modules/
97
100
  },
98
101
  {
@@ -134,7 +137,7 @@ module.exports = (option) => {
134
137
  {
135
138
  test: /\.(js|ts|tsx|jsx|vue|css|html)$/,
136
139
  loader: 'params-replace-loader',
137
- include: [resolve('src')],
140
+ include: curProjectDir, // [resolve('src')],
138
141
  exclude: [/node_modules/, resolve('src/mock/data')], // 排除不需要进行校验的文件夹
139
142
  options: config.envParams
140
143
  }
@@ -153,7 +156,7 @@ module.exports = (option) => {
153
156
  test: /\.tsx?$/,
154
157
  loader: 'eslint-loader',
155
158
  enforce: 'pre',
156
- include: [resolve('src')],
159
+ include: curProjectDir, // [resolve('src')],
157
160
  exclude: /node_modules/,
158
161
  options: {
159
162
  cache: true,
@@ -167,7 +170,7 @@ module.exports = (option) => {
167
170
  test: /\.jsx?$/,
168
171
  loader: 'eslint-loader',
169
172
  enforce: 'pre',
170
- include: [resolve('src')],
173
+ include: curProjectDir, // [resolve('src')],
171
174
  exclude: /node_modules/,
172
175
  options: {
173
176
  cache: true, // the cache is written to the ./node_modules/.cache/eslint-loader director
@@ -181,7 +184,7 @@ module.exports = (option) => {
181
184
  test: /\.vue$/,
182
185
  loader: 'eslint-loader',
183
186
  enforce: 'pre',
184
- include: [resolve('src')],
187
+ include: curProjectDir, // [resolve('src')],
185
188
  exclude: /node_modules/,
186
189
  options: {
187
190
  cache: true,