Skip to content

Instantly share code, notes, and snippets.

@suisho
Last active August 29, 2015 14:20
Show Gist options
  • Save suisho/c71ecd98d1ec4e10fdc9 to your computer and use it in GitHub Desktop.
Save suisho/c71ecd98d1ec4e10fdc9 to your computer and use it in GitHub Desktop.
electronでbabel + reactを直接使えるようにするまで ref: http://qiita.com/suisho/items/a3822167604e5ad6c19b
$ tree -I node_modules
.
├── app
│   ├── client
│   │   ├── Foo.jsx
│   │   └── main.jsx
│   ├── index.html
│   └── index.js
└── package.json
$ npm init -y
$ npm i -S babel react electron-prebuilt
$ npm start
<!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>
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)
{
"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