React with webpack

zyip發表於2015-08-06

 

 

//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/

 

相關文章