Last active
March 22, 2017 08:06
-
-
Save saitoxu/70b7d3522332f55afbbad275c62abc6b to your computer and use it in GitHub Desktop.
2017-03-20
This file contains hidden or 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 Friend from './friend'; | |
let friend = new Friend('Taro'); | |
friend.callName(); |
This file contains hidden or 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
$ yarn run build | |
yarn run v0.21.3 | |
$ `yarn bin`/webpack | |
Hash: 4275ae52df5e0f0a5001 | |
Version: webpack 2.2.1 | |
Time: 502ms | |
Asset Size Chunks Chunk Names | |
application.js 5.58 kB 0 [emitted] application | |
[0] ./friend.js 2.15 kB {0} [built] | |
[1] ./person.js 356 bytes {0} [built] | |
[2] ./application.js 258 bytes {0} [built] | |
✨ Done in 1.43s. | |
$ hs | |
Starting up http-server, serving ./ | |
Available on: | |
http://127.0.0.1:8080 | |
http://192.168.1.8:8080 | |
http://192.168.33.1:8080 | |
Hit CTRL-C to stop the server |
This file contains hidden or 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 Person from './person'; | |
class Friend extends Person { | |
constructor(name) { | |
super(name); | |
} | |
callName() { | |
alert(this.name); | |
} | |
} | |
export default Friend; |
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>JS Tutorial</title> | |
<script src="dst/application.js"></script> | |
</head> | |
<body> | |
<h1>JS Tutorial</h1> | |
</body> | |
</html> |
This file contains hidden or 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
$ mkdir js-tutorial && cd js-tutorial | |
$ yarn init | |
$ yarn add -D webpack babel-core babel-loader babel-preset-es2015 | |
$ yarn # インストール |
This file contains hidden or 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": "js-tutorial", | |
"scripts": { | |
"build": "`yarn bin`/webpack" | |
}, | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"devDependencies": { | |
"babel-core": "^6.24.0", | |
"babel-loader": "^6.4.1", | |
"babel-preset-es2015": "^6.24.0", | |
"webpack": "^2.2.1" | |
}, | |
"dependencies": {} | |
} |
This file contains hidden or 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
class Person { | |
constructor(name) { | |
this.name = name; | |
} | |
} | |
export default Person; |
This file contains hidden or 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 | |
├── dst | |
│ └── application.js # webpackでコンパイルしたJSファイル | |
├── index.html | |
├── node_modules | |
│ └── ... | |
├── package.json | |
├── src | |
│ └── ... # sourceファイル群 | |
├── webpack.config.js | |
└── yarn.lock |
This file contains hidden or 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
module.exports = { | |
context: __dirname + '/src', | |
entry: { | |
'application': './application', | |
}, | |
output: { | |
path: __dirname + '/dst', | |
filename: '[name].js' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: "babel-loader", | |
query: { | |
presets: ['es2015'] | |
} | |
} | |
] | |
} | |
}; |
This file contains hidden or 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
$ brew update | |
$ brew install yarn | |
$ yarn -v | |
yarn install v0.21.3 | |
[1/4] 🔍 Resolving packages... | |
success Already up-to-date. | |
✨ Done in 0.36s. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment