美文网首页
webpack 环境配置

webpack 环境配置

作者: debt | 来源:发表于2016-08-24 09:03 被阅读25次

    webpack.config.js

    {
      "name": "learnreact",
      "version": "1.0.0",
      "description": "React ",
      "main": "webpack.config.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
         "start": "./node_modules/.bin/webpack-dev-server --content-base src   --inline --hot",
        "build": "webpack --display-error-details",
        "watch": "webpack --progress --colors --watch"
      },
      "keywords": [
        "react"
      ],
      "author": "",
      "license": "ISC",
      "dependencies": {
        "babel-core": "^6.11.4",
        "babel-loader": "^6.2.4",
        "babel-plugin-add-module-exports": "^0.2.1",
        "babel-plugin-react-html-attrs": "^2.0.0",
        "babel-plugin-transform-class-properties": "^6.11.5",
        "babel-plugin-transform-decorators-legacy": "^1.3.4",
        "babel-preset-es2015": "^6.9.0",
        "babel-preset-react": "^6.11.1",
        "babel-preset-stage-0": "^6.5.0",
        "react": "^15.2.1",
        "react-dom": "^15.2.1",
        "webpack": "^1.13.2",
        "webpack-dev-server": "^1.15.0"
      }
    }
    
    

    package.json

    {
      "name": "learnreact",
      "version": "1.0.0",
      "description": "React ",
      "main": "index.js",
      "scripts": {
        "dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot",
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/cathyleeu/react-learncodeacademy.git"
      },
      "keywords": [
        "react"
      ],
      "author": "cathyleeu",
      "license": "ISC",
      "bugs": {
        "url": "https://github.com/cathyleeu/react-learncodeacademy/issues"
      },
      "homepage": "https://github.com/cathyleeu/react-learncodeacademy#readme",
      "dependencies": {
        "babel-core": "^6.11.4",
        "babel-loader": "^6.2.4",
        "babel-plugin-add-module-exports": "^0.2.1",
        "babel-plugin-react-html-attrs": "^2.0.0",
        "babel-plugin-transform-class-properties": "^6.11.5",
        "babel-plugin-transform-decorators-legacy": "^1.3.4",
        "babel-preset-es2015": "^6.9.0",
        "babel-preset-react": "^6.11.1",
        "babel-preset-stage-0": "^6.5.0",
        "react": "^15.2.1",
        "react-dom": "^15.2.1",
        "webpack": "^1.13.1",
        "webpack-dev-server": "^1.15.0"
      }
    }
    
    

    client.js

    import React from 'react';
    import ReactDOM from 'react-dom';
    
    class Layout extends React.Component{
        render(){
            return(
                <p>ws!!!ooh</p>
                );
        }
    }
    
    const app=document.getElementById('app');
    ReactDOM.render(<Layout/>,app);
    

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
    <div id='app'></div>
        <script src='client.min.js'></script>
    </body>
    </html>
    

    相关文章

      网友评论

          本文标题:webpack 环境配置

          本文链接:https://www.haomeiwen.com/subject/ohgnsttx.html