Last active
August 29, 2015 14:20
-
-
Save suisho/c71ecd98d1ec4e10fdc9 to your computer and use it in GitHub Desktop.
electronでbabel + reactを直接使えるようにするまで ref: http://qiita.com/suisho/items/a3822167604e5ad6c19b
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
$ tree -I node_modules | |
. | |
├── app | |
│ ├── client | |
│ │ ├── Foo.jsx | |
│ │ └── main.jsx | |
│ ├── index.html | |
│ └── index.js | |
└── package.json |
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
$ npm init -y | |
$ npm i -S babel react electron-prebuilt |
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
$ npm start |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
We are using io.js | |
<div id="container"></div> | |
<script> | |
window.onload = function(){ | |
require('babel/register')() //ここ重要 | |
require("./client/main.jsx") | |
} | |
</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
import React from 'react' | |
class Foo extends React.Component{ | |
render(){ | |
return <div>This is React component</div> | |
} | |
} | |
var container = document.querySelector("#container") | |
React.render(<Foo />, container) |
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
{ | |
"name": "example-electron-babel", | |
"version": "1.0.0", | |
"description": "app", | |
"scripts": { | |
"start": "electron ./app" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"babel": "^5.2.17", | |
"electron-prebuilt": "^0.25.3", | |
"react": "^0.13.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment