浏览代码

Minimum setup

Snow 8 年之前
当前提交
18f8526875
共有 6 个文件被更改,包括 3659 次插入0 次删除
  1. 1 0
      .gitignore
  2. 31 0
      package.json
  3. 10 0
      public/index.html
  4. 11 0
      src/index.js
  5. 27 0
      webpack.config.js
  6. 3579 0
      yarn.lock

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+node_modules

+ 31 - 0
package.json

@@ -0,0 +1,31 @@
+{
+  "name": "react-boilerplate",
+  "version": "1.0.0",
+  "main": "index.js",
+  "license": "MIT",
+  "babel": {
+    "presets": [
+      "es2015",
+      "react",
+      "stage-2"
+    ],
+    "plugins": ["react-hot-loader/babel"]
+  },
+  "devDependencies": {
+    "babel-core": "^6.25.0",
+    "babel-loader": "^7.1.0",
+    "babel-preset-es2015": "^6.24.1",
+    "babel-preset-react": "^6.24.1",
+    "babel-preset-stage-2": "^6.24.1",
+    "webpack": "^3.0.0",
+    "webpack-dev-server": "^2.5.0"
+  },
+  "scripts": {
+    "start": "webpack-dev-server --progress --colors --hot --config ./webpack.config.js"
+  },
+  "dependencies": {
+    "react": "^15.6.1",
+    "react-dom": "^15.6.1",
+    "react-hot-loader": "next"
+  }
+}

+ 10 - 0
public/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+  <head>
+      <title>My react boilerplate</title>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script src="bundle.js"></script>
+  </body>
+</html>

+ 11 - 0
src/index.js

@@ -0,0 +1,11 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+
+const title = <h2>Test setup</h2>;
+
+ReactDOM.render(
+  <div>{title}</div>,
+  document.getElementById('app')
+);
+
+module.hot.accept();

+ 27 - 0
webpack.config.js

@@ -0,0 +1,27 @@
+module.exports = {
+  entry: [
+    'webpack-dev-server/client?http://localhost:8080',
+    'webpack/hot/only-dev-server',
+    'react-hot-loader/patch',
+    './src/index.js'
+  ],
+  module: {
+    loaders: [{
+      test: /\.jsx?$/,
+      exclude: /node_modules/,
+      loaders: ['react-hot-loader/webpack','babel-loader'],
+    }]
+  },
+  resolve: {
+    extensions: ['*', '.js', '.jsx']
+  },
+  output: {
+    path: __dirname + '/public',
+    publicPath: '/',
+    filename: 'bundle.js'
+  },
+  devServer: {
+    contentBase: './public',
+    hot: true
+  }
+};

文件差异内容过多而无法显示
+ 3579 - 0
yarn.lock