-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
luoxue
committed
Dec 10, 2019
1 parent
83d51b1
commit 1e0a526
Showing
21 changed files
with
222 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
// [提取 manifest] | ||
module.exports = ({ config }) => { | ||
return () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 课题 1: 初探 webpack | ||
## 课题01:初探 webpack | ||
|
||
想要学好 `webpack`,我们首先要了解 `webpack` 的机制,我们先从js加载css开始学习。 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 课题 2:搭建可插拔的开发环境跟生产环境 | ||
## 课题02:搭建可插拔的开发环境跟生产环境 | ||
|
||
本章提要: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 课题 3:基础配置(loder,ts、babel、css、less、sass、postcss)等 | ||
## 课题03:基础配置(loder,ts、babel、css、less、sass、postcss)等 | ||
|
||
本章提要: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 课时 4:webpack 性能优化1 | ||
## 课题04:webpack 性能优化1 | ||
|
||
本章讲解 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 手写一个loader,实现可选链 | ||
## 课题05: 手写一个loader,实现可选链 | ||
|
||
本章内容 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## webpack编译优化 | ||
## 课题06: webpack编译优化 | ||
|
||
本章内容 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## 多页面配置 | ||
## 课题07:多页面配置 | ||
|
||
**注意** | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## webpack 构建 ssr | ||
## 课题09:webpack 构建 ssr | ||
|
||
ssr 就是服务端渲染,做 ssr 的好处就是为了处理 spa 的不足,比如 seo 优化,服务端缓存等问题。 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 添加 eslint 并开启自动修复 | ||
## 课题10:添加 eslint 并开启自动修复 | ||
|
||
本章概要 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 添加 stylelint | ||
## 课题11:添加 stylelint | ||
|
||
本章概要 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 添加 tslint | ||
## 课题12:添加 tslint | ||
|
||
本章概要 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,76 @@ | ||
#!/usr/bin/env node | ||
console.log('----------创建readme-------') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const readmePath = path.join('util', 'readme') | ||
|
||
let configCtx = '', | ||
docsCtx = '' | ||
|
||
configCtx = extraTxt('config', function(firstRow) { | ||
return firstRow.replace('// ', '') | ||
}) | ||
|
||
docsCtx = extraTxt('docs', function(firstRow) { | ||
return `[${firstRow.replace('## ', '')}]` | ||
}) | ||
|
||
function joinCtx () { | ||
let str = '' | ||
str += readMdBy('header') | ||
str += detailTag('所有课题', docsCtx) | ||
str += readMdBy('useAndIntsall') | ||
str += detailTag('所有配置', configCtx) | ||
str += boxConfig() | ||
return str | ||
} | ||
|
||
const ctx = joinCtx() | ||
|
||
fs.writeFileSync('README.md', ctx, 'utf-8') | ||
|
||
function detailTag (title, ctx) { | ||
return ` | ||
### ${title} | ||
<details open=“open”> | ||
<summary>点击关闭/打开${title}</summary> \n\n${ctx} | ||
</details>` | ||
} | ||
|
||
function extraTxt (dirname, firstRowStrategy) { | ||
const files = fs.readdirSync(dirname) | ||
let ctx = '' | ||
files.forEach(file => { | ||
const absolutePath = path.join(process.cwd(), dirname, file) | ||
if (fs.statSync(absolutePath).isDirectory()) return | ||
const content = fs.readFileSync(absolutePath).toString() | ||
const firstRow = content.split('\n')[0].trim() | ||
const title = firstRowStrategy(firstRow) | ||
ctx += `- ${title}(./${dirname}/${file})\n` | ||
}) | ||
return ctx | ||
} | ||
|
||
function boxConfig () { | ||
let ctx = '' | ||
ctx = fs.readFileSync(path.join(process.cwd(), 'box.config.js')).toString() | ||
return ` | ||
### 扩展配置 | ||
<details open=“open”> | ||
<summary>点击关闭/打开扩展配置</summary> | ||
在根目录下添加 \`box.config.js\`,即可配置使用 | ||
box.config.js | ||
\`\`\`js | ||
${ctx} | ||
\`\`\` | ||
</details> | ||
` | ||
} | ||
|
||
function readMdBy(name) { | ||
return fs.readFileSync(path.join(readmePath, name + '.md')).toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# webpack 工程师的自我修养 | ||
|
||
> 本来想要做一个大型项目的 webpack 教程,但是我发现还可以做更多的事情,所以这里我要将这个项目做成 webpack 手册,您可以来这里找到任何想要的 webpack 配置 | ||
本文从下面几个课题来实现 |
Oops, something went wrong.