Skip to content

Commit

Permalink
fix(react): 重新提交react
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxue committed Dec 21, 2019
1 parent 0eee296 commit 97be6d3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 🌟 新功能
范围|描述|commitId
--|--|--
react | 增加react并规范了目录 | [0eee296](https://github.com/luoxue-victor/learn_webpack/commit/0eee296)
增加react配置 | [76c0fe1](https://github.com/luoxue-victor/learn_webpack/commit/76c0fe1), closes [#8](https://github.com/luoxue-victor/learn_webpack/issues/8)
dist | 删除dist | [9600d82](https://github.com/luoxue-victor/learn_webpack/commit/9600d82)
packages | 新加cli跟utils包 | [0828922](https://github.com/luoxue-victor/learn_webpack/commit/0828922)
Expand Down
47 changes: 47 additions & 0 deletions docs/课时-24.md
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
## 课时 24:配置 react

基础配置已经全部配置好了,所以 react 的配置就只有将 jsx 的文件用 babel 编译一下就 ok 了,下面配置将 babel 的配置进行了修改

开启 react

box.config.js

```js
{
"env": {
"REACT": "react" // 配置 react
}
}
```

packages/react/webpack-chain.config.js

```js
// [react 配置]
module.exports = ({ config }) => {
return () => {
if (!process.env.REACT) return;
const baseRule = config.module.rule("babel");
baseRule
.use("babel")
.loader(require.resolve("babel-loader"))
.tap(options => {
options.presets.push([
"@babel/preset-react",
{
corejs: "3",
useBuiltIns: "usage",
loose: true,
modules: false,
targets: {
chrome: 59,
edge: 13,
firefox: 50,
safari: 8
}
}
]);
return options;
});
};
};
```
5 changes: 0 additions & 5 deletions util/createReadme.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@ const packageConfig = extraTxtFromDirWithFilename(
return `[${firstRow.replace('// ', '')}]`
})

console.log(packageConfig)

function joinCtx () {
let str = ''
str += readMdBy('header')
str += detailTag('所有课题', docsCtx, false)
str += readMdBy('useAndIntsall')
str += detailTag('所有配置', configCtx + packageConfig)
// str += extraTxtFromDirWithFilename('packages', 'webpack-chain.config.js')
str += boxConfig()
return str
}

// console.log(extraTxtFromDirWithFilename('packages', 'webpack-chain.config.js'))

const ctx = joinCtx()

fs.writeFileSync('README.md', ctx, 'utf-8')
Expand Down

0 comments on commit 97be6d3

Please sign in to comment.