-
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 21, 2019
1 parent
0eee296
commit 97be6d3
Showing
3 changed files
with
48 additions
and
5 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
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; | ||
}); | ||
}; | ||
}; | ||
``` |
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