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

我が家の web フロントエンド開発・ビルド環境の遍歴

wakamsha
June 05, 2017

我が家の web フロントエンド開発・ビルド環境の遍歴

2017年6月5日の『We Are JavaScripters! @8th』で発表した資料です。

私がこれまで使用してきた web フロントエンド開発におけるビルド環境の遍歴をご紹介しています。それぞれの概要やユースケースは勿論、なぜそれを使うのをやめたのかについても言及しています。

#WeJS

wakamsha

June 05, 2017
Tweet

More Decks by wakamsha

Other Decks in Technology

Transcript

  1. զ͕Ոͷ XFCϑϩϯτΤϯυ։ൃɾϏϧυ؀ڥͷวྺ - The itinerant history of our web frontend

    dev & build environment -  /BPLJ:"."%" !XBLBNTIB 8F"SF+BWB4DSJQUFST!UI
  2. $ gem install middleman $ middleman init my-project $ middleman

    server $ middleman build w ๛෋ͳϔϧύʔϝιου w 3BJMTͱಉ͡΋ͷ͕΄΅࢖༻Մೳ w ࠷ॳ͔ΒϏϧυ؀ڥ͕׬੒͍ͯ͠ΔͷͰ௒ઈ͓खܰ w ֤छϝλݴޠͷίϯύΠϧ w -JWF3FMPBE w "TTFU1JQFMJOF +4 $44ͷ݁߹ϛχϑΝΠԽ  w FUDʜ
  3. w ϓϩμΫτͷXFCϑϩϯτΤϯυ։ൃͱ͍͏ΑΓ͸ ϓϩτλΠϐϯά؀ڥͱͯ͠׆༻ w 6*ݕূͷͨΊͷϞοΫΞοϓ w σϞ༻ w ͜Ε͕͔͋ͬͨΒࠓ೔ͷࣗ෼͕͍Δͱݴͬͯ΋աݴͰ ͸ͳ͍

    w "MU+4 "MU$44ͰίʔσΟϯά͠ɺϩʔΧϧαʔόͰಈ࡞֬ೝ͢Δ ͱ͍͏։ൃϑϩʔΛҰ௨Γମײ͢Δ͜ͱ͕ग़དྷͨ 6TFDBTF
  4. w ϓϥάΠϯ /PEFϞδϡʔϧ ͕๛෋ w ͦΕΒΛ૊Έ߹Θͤͯཁ݅ʹదͨ͠Ϗϧυ؀ڥΛߏங w ֤छϝλݴޠ 5ZQF4DSJQU4$44+BEFʜ ͷίϯύΠϧ

    w ϩʔΧϧαʔόͷىಈ w -JWF3FMPBE w +4 $44ͷ݁߹ϛχϑΝΠԽ w FUDʜ w gruntfile.jsʹϋογϡܗࣜͰλεΫΛఆٛ w ˞$P⒎FF4DSJQUͰ΋هड़Մೳ
  5. w େن໛41"։ൃҊ݅ͷϑϩϯτΤϯυ։ൃج൫ w 5ZQF4DSJQU4$44+BEF 1VH ͷίϯύΠϧ w ϓϩμΫγϣϯίʔυͱґଘϥΠϒϥϦͱͷ݁߹ w ϩʔΧϧαʔόͷىಈͱXBUDI

    -JWF3FMPBE  w Ϗϧυ؀ڥͷຊ֨తͳߏஙϊ΢ϋ΢ͷଟ͘Λ͜ͷஈ֊ Ͱशಘ w /PEFKTͷ֓ཁ΋͜ͷࠒʹֶΜͩ ˞ͦ͜·Ͱਂ͘͸ཧղͯ͠ͳ͍ 6TFDBTF
  6. Browserify lets you require ( ‘modules’ ) in the browser

    by bundling up all of your dependencies - 2016.mid ~ 2016.later - Use Browserify
  7. npm scripts the “scripts” property of the package.json script, for

    following scripts - 2017.early ~ Now - npm-scripts
  8. iTerm my-project > npm run build > [email protected] watch /path/to/your/project/my-project

    > node ./bin/build.js ⋮ w λεΫࣗମ͸TIϑΝΠϧ΍KTϑΝΠϧʹఆٛ w OQNTDSJQUT͸ͦΕΒΛ࣮ߦ͢Δ͚ͩ w .shͳΒbash task.sh w jsͳΒnode task.js w $JSDMF$*ͷcircle.ymlΈ͍ͨͳΠϝʔδ w (VMQ΄ͲෳࡶͳλεΫͷఆٛʹ͸޲͔ͳ͍͕ɺ͋Δ ఔ౓͸͜Ε͚ͩͰॆ෼ΧόʔՄೳ
  9. iTerm my-project > npm run build > [email protected] watch /path/to/your/project/my-project

    > node ./bin/build.js ⋮ w /PEFϞδϡʔϧؒͷґଘ͕ܹݮ w (VMQ༻ͷϥούʔϞδϡʔϧ͕ෆཁ w ΞοϓσʔτʹΑΔյ໓ͱ͍͏ϦεΫ͕ܹݮ w ࣮ߦ଎౓͕ܶతʹ޲্
  10. my-project > npm run build > [email protected] watch /path/to/your/project/my-project >

    node ./bin/build.js ⋮ iTerm w ݱߦͷ41"։ൃͷͨΊͷج൫ w 5ZQF4DSJQU4UZMVT1VHͷίϯύΠϧ w CSPXTFSJGZͰ+4Ϟδϡʔϧͷґଘؔ܎ΛղܾϑΝΠϧ݁߹ w ϑϩϯτΤϯυɾΤίγεςϜͷਐԽʹ൐ͬͯλεΫ ఆ͕ٛ؆ུԽ w +4ϑϨʔϜϫʔΫ͕ద੾ʹϞδϡʔϧԽ͞Ε͍ͯΔ w #PXFSΛ࢖Θͣͱ΋ຆͲͷ+4ϥΠϒϥϦ͕OQNܦ༝ͰΠϯε τʔϧͰ͖ΔΑ͏ʹͳͬͨ 6TFDBTF
  11. { "name": “my-project", "version": "1.0.0", "main": "index.js", "scripts": { "build":

    “node ./bin/build.js” }, "dependencies": { "@cycle/dom": "^17.3.0", "@cycle/run": "^3.1.0", "@cycle/rxjs-run": “^7.0.0", "ramda": "^0.24.1", "rxjs": "^5.4.0", "xstream": "^10.8.0" }, "devDependencies": { "browser-sync": "^2.18.11", "browserify": "^14.3.0", "connect-modrewrite": "^0.10.1", "pug": "^2.0.0-rc.1", "pug-cli": "^1.0.0-alpha6", "stylus": "^0.54.5", "tsify": "^3.0.1", "typescript": "^2.3.2", "watchify": "^3.9.0" } } package.json
  12. { "name": “my-project", "version": "1.0.0", "main": "index.js", "scripts": { "build":

    “node ./bin/build.js” }, "dependencies": { "@cycle/dom": "^17.3.0", "@cycle/run": "^3.1.0", "@cycle/rxjs-run": “^7.0.0", "ramda": "^0.24.1", "rxjs": "^5.4.0", "xstream": "^10.8.0" }, "devDependencies": { "browser-sync": "^2.18.11", "browserify": "^14.3.0", "connect-modrewrite": "^0.10.1", "pug": "^2.0.0-rc.1", "pug-cli": "^1.0.0-alpha6", "stylus": "^0.54.5", "tsify": "^3.0.1", "typescript": "^2.3.2", "watchify": "^3.9.0" } } package.json // Compile Pug sources execSync(`pug src/templates -o public -w`); // Compile Stylus sources execSync(`stylus src/styles/style.styl -o public/assets/style.css`); // Compile TypeScript sources let b = browserify({ entries: ['./src/scripts/main.ts'], cache: {}, packageCache: {}, plugin: [watchify], debug: true }) .plugin(tsify); b.on('update', bundle) bundle(); function bundle() { b.bundle().on('error', (err) => { console.log(err.message); }).pipe(fs.createWriteStream('./public/assets/main.js')); } // Run Server browserSync.create().init({ files: ['public'], server: { baseDir: ['public'] }, startPath: '/', reloadDebounce: 500 }); build.js
  13. { "name": “my-project", "version": "1.0.0", "main": "index.js", "scripts": { "build":

    “node ./bin/build.sh” }, "dependencies": { "@cycle/dom": "^17.3.0", "@cycle/run": "^3.1.0", "@cycle/rxjs-run": “^7.0.0", "ramda": "^0.24.1", "rxjs": "^5.4.0", "xstream": "^10.8.0" }, "devDependencies": { "browser-sync": "^2.18.11", "browserify": "^14.3.0", "connect-modrewrite": "^0.10.1", "pug": "^2.0.0-rc.1", "pug-cli": "^1.0.0-alpha6", "stylus": "^0.54.5", "tsify": "^3.0.1", "typescript": "^2.3.2", "watchify": "^3.9.0" } } package.json #!/usr/bin/env bash # Compile Pug sources nohup pug src/templates -o public -w & pug_pid=$! trap "kill -15 $pug_pid &>/dev/null" 2 15 # Compile Stylus sources nohup stylus src/styles/app.styl -o public/assets -m -w & stylus_pid=$! trap "kill -15 $stylus_pid &>/dev/null" 2 15 # Compile TypeScript sources nohup watchify -d src/scripts/main.ts -p [ tsify ] -o public/assets/ app.js & watchify_pid=$! trap "kill -15 $watchify_pid $>/dev/null" 2 15 # Run Server nohup browser-sync start --config bs-config.js & browserSync_pid=$! trap "kill -15 $browserSync_pid &>/dev/null" 2 15 tail -f nohup.out build.sh