Upgrade to Pro — share decks privately, control downloads, hide ads and more …

my tools

my tools

8/10の社内勉強会資料

Yuta Hiroto

August 10, 2016
Tweet

More Decks by Yuta Hiroto

Other Decks in Technology

Transcript

  1. τϥϯεύΠϥͱ͸ʁ • ৽͍͠ߏจΛࠓͷ࣌୅ͷ ϒϥ΢βͰ΋ಈ͘Α͏ʹ ίʔυΛు͍ͯ͘ΕΔ
 πʔϧ • ϒϥ΢βʹΑͬͯ৽͍͠ ߏจͷ࣮૷Ϩϕϧ͕ҟͳ Δ͕ɺ։ൃऀ͸ͦΕΛ


    ؾʹ͠ͳͯ͘΋Α͘ͳΔ const post = (mail = 'tegami') => { const index = 0 } 'use strict'; var post = function post() { var mail = arguments.length <= 0 || arguments[0] === undefined ? 'tegami' : arguments[0]; var index = 0; };
  2. ES2015 • ECMAScriptͱ͍͏JavaScriptͷඪ४ن֨Ͱ
 ES2015(ES6)ͱ͸ୈ6൛ͷϦϦʔε • arrows • classes • enhanced

    object literals • template strings • destructuring • default + rest + spread • let + const • iterators + for..of • generators • unicode • modules • module loaders • map + set + weakmap + weakset • proxies • symbols • subclassable built-ins • promises • math + number + string + array + object APIs • binary and octal literals • reflect api • tail calls ௥Ճ͞Εͨػೳ
  3. webpack • σϑΥϧτͰAMDͱCommonJSΛαϙʔτ͍ͯ͠Δ • Sass, Less, Coffee, TypeScriptͳͲΛม׵ • css,

    imageͳͲΛϞδϡʔϧͱͯ͠ಡΈࠐΈ͜ͱ͕Մೳ • Loader΍PluginΛ࢖͏͜ͱʹΑΓ֦ு͕Մೳ • ެࣜͷϦετʹΑΔͱେମLoader͸228ݸ, Plugin͸56ݸଘࡏ͢Δ • ෳ਺ͷόϯυϧϑΝΠϧΛग़ྗ͢Δ͜ͱ͕Մೳ • ։ൃ΍ϓϩμΫγϣϯͷઃఆ͕σϑΥϧτͰ͋Δ(sourceMap, uglify…) • dev-server΋ެࣜͰఏڙ͞Ε͍ͯΔ ॻ͖͖Εͳ͍͙Β͍ͳΜͰ΋Ͱ͖Δʂ
  4. npm-scripts "scripts": { "test": "ava", "test:watch": "ava -w", "lint": "eslint

    src", "start": "webpack-dev-server", "build": "webpack --config ./webpack.production.config.js" } ͜ͷΑ͏ʹॻ͘͜ͱ͕ՄೳͰ͋Δ $ npm start $ npm run test:watch package.jsonʹίϚϯυΛॻ͘͜ͱ͕Ͱ͖Δ
  5. package.jsonΛ࡞Δ $ npm init { "name": "test", "version": "1.0.0", "description":

    "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "abouthiroppy <[email protected]>", "license": "MIT" }
  6. ϥΠϒϥϦΛೖΕΔ $ npm i webpack babel-loader -D # package.json΁௥Ճ͞ΕΔ "devDependencies":

    { "babel-loader": "^6.2.4", "webpack": "^1.13.1" } -D(—-save-dev) option
 
 devDependenciesʹ
 Πϯετʔϧͨ͠ϥΠϒϥϦ
 ͕ొ࿥͞ΕΔ
  7. ઃఆϑΝΠϧΛॻ͘ 'use strict'; const path = require('path'); module.exports = {

    // Ҿ਺Ͱ౉͢ͳΒentry, output, resolve͸ॻ͔ͳͯ͘΋ྑ͍ entry: path.join(__dirname, 'index.js'), output: { filename: path.join(__dirname, 'bundle.js') }, resolve: { extensions: ['', '.js'] }, module: { loaders: [ { test: /\.js$/, loader: 'babel', exclude: path.join(__dirname, 'node_modules') } ] } } webpack.config.js
  8. ಈ͔͢ { "scripts": { "test": "echo \"Error: no test specified\"

    && exit 1", "start": "webpack -w", "build": "webpack -p" } } ޙ͸htmlͰຒΊࠐΈϒϥ΢βͰ࢖͑Δঢ়ଶʹͳΓ׬੒ʂ package.jsonʹίϚϯυΛొ࿥͢Δͱָ npm start Λߦ͏ͱϑΝΠϧ؂ࢹ͕Ͱ͖Δ npm run buildΛߦ͏ͱ
 ϓϩμΫγϣϯ༻ͷίʔυ͕ੜ੒͞ΕΔ