当前位置:首页 » 其他

React with webpack

2015-08-06 09:50 本站整理 浏览(7)
//entry.js

require("!style!css!./style.css");
require("./hello.jsx");

// document.write("It works.");
document.write(require("./content.js"));

//hello.jsx
var React = require('react');

 var e = document.createElement('div'); 
     e.id='example';
    document.body.appendChild(e); 

React.render(
  <h1>Hello, world!</h1>,
  document.getElementById('example')
);

module.exports = {
    entry: "./entry.js",
    output: {
        path: __dirname,
        filename: "bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" },
            { test: /\.jsx$/, loader: "jsx-loader" }
        ]
    }
};

http://jslog.com/2014/10/02/react-with-webpack-part-1/
http://gaearon.github.io/react-hot-loader/getstarted/