专栏名称: 蚂蚁金服ProtoTeam
数据前端团队
目录
相关文章推荐
51好读  ›  专栏  ›  蚂蚁金服ProtoTeam

Parcel 打包示例 - React HelloWorld

蚂蚁金服ProtoTeam  · 掘金  · 前端  · 2017-12-07 08:03

正文

请到「今天看啥」查看全文


yarn add react react-dom

npm:

npm install react react-dom --save

package.json 文件内容:

 {
   "name": "parcel-example-react-helloworld",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "keywords": [],
   "author": "",
-  "license": "ISC"
+  "license": "ISC",
+  "dependencies": {
+    "react": "^16.2.0",
+    "react-dom": "^16.2.0"
+  }
 }

3. 添加 Babel

新建 .babelrc 文件

touch .babelrc

输入内容:

{
  "presets": ["react"]
}

添加 babel-preset-react:

yarn:

yarn add babel-preset-react -D

npm:

npm install babel-preset-react --D

此时 package.json 文件内容:

 {
   "name": "parcel-example-react-helloworld",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "keywords": [],
   "author": "",
   "license": "ISC",
   "dependencies": {
     "react": "^16.2.0",
     "react-dom": "^16.2.0"
-   }






请到「今天看啥」查看全文