akfun 5.2.1 → 5.2.2

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
@@ -22,7 +22,7 @@ AKFun 是一个基于 Webpack 与 Rollup 的多场景前端打包工具,支持
22
22
 
23
23
  - **零配置**: 内置默认配置,开箱即用
24
24
  - **多技术栈**: 支持 Vue、React、React+TS 的调试与构建
25
- - **多构建场景**: 本地开发(含热更新/代理)、生产构建、库构建(UMD/ESM
25
+ - **多构建场景**: 本地开发(含热更新/代理)、生产构建、库构建(UMD/ESM)、Node 模块构建
26
26
  - **灵活可配**: 支持入口、别名、代理、SASS 注入、ESLint/StyleLint、Babel/Loader/Plugin 扩展等配置
27
27
  - **样式与规范**: 集成 Autoprefixer、Sass、PostCSS、ESLint、StyleLint
28
28
  - **参数替换**: 支持基于 [params-replace-loader](https://www.npmjs.com/package/params-replace-loader) 的环境变量批量替换
@@ -114,6 +114,7 @@ npm i akfun --save-dev
114
114
  | `akfun build` | 生产环境构建(压缩优化、可选分析) |
115
115
  | `akfun build2lib` | 构建 UMD 格式的库产物 |
116
116
  | `akfun build2esm` | 构建 ESM 格式的库产物 |
117
+ | `akfun build2node` | 构建 Node 模块 |
117
118
 
118
119
  ---
119
120
 
@@ -379,6 +380,20 @@ module.exports = {
379
380
  }
380
381
  ```
381
382
 
383
+ #### 构建 Node 模块
384
+
385
+ 构建 Node 模块,通常用于构建 node cli 工具:
386
+
387
+ ```javascript
388
+ module.exports = {
389
+ build2node: {
390
+ input: resolve('src/main.js'), // 入口文件
391
+ fileName: 'index', // 输出的文件名称
392
+ outDir: 'src' // 输出目录
393
+ }
394
+ }
395
+ ```
396
+
382
397
  ---
383
398
 
384
399
  ### 高级配置
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
package/src/build2node.js CHANGED
@@ -12,6 +12,7 @@ const rollupConfig = require('./rollup/rollup.node.config'); // rollup的配置
12
12
  * - input: 构建入口文件
13
13
  * - fileName: 构建输出文件名
14
14
  * - outDir: 构建输出目录
15
+ * - preserveModules: 是否保留原始模块结构,不合并文件
15
16
  * - excludeList: 构建排除列表
16
17
  * - declaration: 是否生成声明文件
17
18
  * - declarationDir: 声明文件输出目录
@@ -74,9 +74,9 @@ module.exports = function (curConfig, curEnvConfig) {
74
74
  json()
75
75
  ],
76
76
  output: {
77
- dir: resolve('dist'),
77
+ dir: curEnvConfig.outDir || resolve('dist'),
78
78
  format: buildFormat, // which can be one of "amd", "cjs", "system", "es", "iife" or "umd".
79
- preserveModules: true, // 关键:保留原始模块结构,不合并文件
79
+ preserveModules: curEnvConfig.preserveModules !== undefined ? curEnvConfig.preserveModules : true, // 关键:保留原始模块结构,不合并文件
80
80
  preserveModulesRoot: 'src', // 指定模块根目录
81
81
  exports: 'auto', // 自动处理导出(适配 ES 模块的默认导出/命名导出)
82
82
  generatedCode: 'es2015', // 使用现代 JavaScript 语法生成代码