Skip to content

Commit

Permalink
fix: loaders support Options
Browse files Browse the repository at this point in the history
  • Loading branch information
imcuttle committed Apr 12, 2018
1 parent 56b348b commit 4211807
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 33 deletions.
14 changes: 7 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"add-module-exports",
"transform-class-properties",
"transform-object-rest-spread",
[
"transform-runtime",
{
"polyfill": false,
"regenerator": true
}
]
// [
// "transform-runtime",
// {
// "polyfill": false,
// "regenerator": true
// }
// ]
],
"ignore": [
]
Expand Down
8 changes: 4 additions & 4 deletions _site/doc/about/why-needs-edam_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ order: 0
---

有没有这样一种痛楚:
- 我们开发项目的时候,其实都是安装大体一致的规范去开发,甚至是一致的文件目录结构。
每当我们需要开发一个新页面的时候,需要将上一个雷同的页面copy&paste,同时需要对里面的名字变量**修修改改**

- 在频繁地造轮子的过程中,需要频繁地书写一致的配置文件到的
* 我们开发项目的时候,其实都是安装大体一致的规范去开发,甚至是一致的文件目录结构。每当我们需要开发一个新页面的时候,需要将上一个雷同的页面 copy&paste,同时需要对里面的名字变量**修修改改**

类似于 `create-react-app` 这些脚手架生成工具,edam提供一个通用的脚手架生成方案。
* 在频繁地造轮子的过程中,需要频繁地书写一致的配置文件到的

类似于 `create-react-app` 这些脚手架 生成工具,edam 提供一个通用的脚手架生成方案。
6 changes: 6 additions & 0 deletions _site/doc/advanced/process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Principle
---

edam
##
38 changes: 38 additions & 0 deletions _site/doc/advanced/process_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "执行流程"
order: 1
---

本文将讲解 Edam 的内部原理。流程如下图:
![](../imgs/edam-process.svg)

1. 读取用户配置
2. [插件](./write-plugin_zh.md)注册
3. 校验配置是否合法(使用[walli](https://github.com/imcuttle/walli)
4. 获取模板来源
5. 安装模板中的依赖
6. 读取模板配置
7. 用户交互输入
8. 载入模板文件资源
9. [处理转换](./write-loader_zh.md)模板文件资源文本,触发生命钩子
10. 输出文件
11. 触发 usefulHooks, post 钩子
12. 结束

### 用户配置

该配置用于用户,用于定义一下模板来源`source/alias`

详细的定义在[选项一节](../usage/options_zh.md).

### 模板(开发者)配置

该配置用于一个模板中,详细请看[如何书写模板](./write-template_zh.md)

### 三种预设模板拉取方式

1. git
2. npm
3. 本地文件

更多介绍参看[特性一节](../features_zh.md)
7 changes: 7 additions & 0 deletions _site/doc/advanced/standalone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "书写模板"
order: 2
---

模板是 Edam 一个重要的概念,可以说核心就是模板的处理。

7 changes: 7 additions & 0 deletions _site/doc/advanced/standalone_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: "书写模板"
order: 2
---

模板是 Edam 一个重要的概念,可以说核心就是模板的处理。

12 changes: 12 additions & 0 deletions _site/doc/advanced/write-loader_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "书写Loader"
order: 3
---

模板配置中与Loader相关的字段有 `mappers` `loaders`

- loaders 形如

{
loaderName: 'sss'
}
File renamed without changes.
24 changes: 24 additions & 0 deletions _site/doc/advanced/write-template_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "书写模板"
order: 2
---

模板是 Edam 一个重要的概念,可以说核心就是模板处理。

流程如下:

1. 根据模板配置中的 `prompts` 数组字段来进行用户输入交互,获取用户输入;
使用 [inquirer.js](https://github.com/SBoudrias/Inquirer.js/)

2. 模板配置中的 `root` 值,root 为模板文件夹的目录,默认为 `./template`
3. 读取 `root` 中的文件数据
4. 分析配置中的 loader,对文件数据进行处理转换
关于 Loader 描述请转至[书写 Loader](./write-loader_zh.md)
* 规则一(最高优先):文件文本,如首行匹配如下任意一种语法:
```text
// @loader ${LOADER_NAME}?${QUERY}
/* @loader ${LOADER_NAME}?${QUERY} */
# @loader ${LOADER_NAME}?${QUERY}
<!-- @loader ${LOADER_NAME}?${QUERY} -->
```
则将使用 LOADER_NAME 进行处理,LOADER_NAME 对应与 `loaders` 中定义的 loader
2 changes: 1 addition & 1 deletion _site/theme-configs/picidae-theme-haier.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
en: 'Advanced',
zh: '进阶学习'
},
url: '/advanced/write-a-template'
url: '/advanced/process'
},
// spec
'i18n', 'search', 'github'
Expand Down
113 changes: 102 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/edam-cli/bin/__tests__/main.spec.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @file main.spec
* @author Cuttle Cong
* @date 2018/3/31
* @description
*/
Expand Down
8 changes: 2 additions & 6 deletions packages/edam-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/edam/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,24 @@
"license": "MIT",
"engines": {
"node": ">=6"
},
"jest": {
"testEnvironment": "node",
"testPathIgnorePatterns": [
".cache"
],
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "((\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
Loading

0 comments on commit 4211807

Please sign in to comment.