This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple demo app and adjust the README file
- Loading branch information
1 parent
eae8c22
commit 8f07a49
Showing
13 changed files
with
166 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["react", "es2015"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# external-jsx-loader demo | ||
|
||
This is some sample code demonstrating a possible scenario using the external-jsx loader. | ||
|
||
--- | ||
|
||
## Building & running | ||
|
||
1. `cd` to the `demo` directory | ||
2. Run `npm install` | ||
3. Run `webpack` | ||
4. Open `index.html` in your browser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>external-jsx-loader demo</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app-entry"></div> | ||
<script src="dist/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "jsx", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-core": "^6.8.0", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"external-jsx-loader": "^1.0.0", | ||
"webpack": "^1.13.0" | ||
}, | ||
"dependencies": { | ||
"react": "^15.0.2", | ||
"react-dom": "^15.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
|
||
const HelloWorld = require('./components/hello-world.js'); | ||
|
||
const AppStart = React.createFactory(HelloWorld); | ||
const AppEntry = document.querySelector('#app-entry'); | ||
|
||
ReactDOM.render(AppStart(), AppEntry); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const React = require('react'); | ||
const view = require('./hello-world.jsx'); // require the template | ||
|
||
class HelloWorld extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = {who: 'World'}; | ||
this.greet = this.greet.bind(this); | ||
this.update = this.update.bind(this); | ||
} | ||
|
||
greet(evt) { | ||
alert(`Hello ${this.state.who}`); | ||
} | ||
|
||
update(evt) { | ||
this.setState({who: evt.target.value}); | ||
} | ||
|
||
render() { | ||
return view(this); // render the template passing `this` as the context | ||
} | ||
} | ||
|
||
module.exports = HelloWorld; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const PageTitle = require('./page-title.js'); | ||
|
||
<div> | ||
<PageTitle name={this.state.who} /> | ||
|
||
<input value={this.state.who} onChange={this.update} type="text" /> | ||
<button onClick={this.greet}>Say hi!</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const React = require('react'); | ||
const view = require('./page-title.jsx'); // require the template | ||
|
||
class PageTitle extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
// some other stuff... | ||
|
||
render() { | ||
return view(this); // render the template passing `this` as the context | ||
} | ||
} | ||
|
||
module.exports = PageTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let theTitle = 'Hello'; | ||
|
||
if (this.props.name !== '') { | ||
theTitle += ' ' + this.props.name; | ||
} | ||
|
||
theTitle += '!'; | ||
|
||
<div> | ||
<h1>{theTitle}</h1> | ||
<hr /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const separator = __dirname.match(/\//) ? '/' : '\\'; | ||
const appRoot = __dirname + separator; | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: { | ||
app: './src/app.js', | ||
}, | ||
output: { | ||
path: appRoot + 'dist', | ||
filename: '[name].js' | ||
}, | ||
resolve: { | ||
extension: ['', '.js'] | ||
}, | ||
stats: { | ||
colors: true, | ||
reasons: true, | ||
chunks: false | ||
}, | ||
plugins: [], | ||
module: { | ||
preLoaders: [ | ||
{test: /\.jsx$/, loader: 'external-jsx', include: appRoot + 'src'} | ||
], | ||
loaders: [ | ||
{test: /\.jsx?$/, loader: 'babel', include: appRoot + 'src'} | ||
] | ||
} | ||
} |