class: center, middle, bgGradient ![image](https://d3ui957tjb5bqd.cloudfront.net/op/font-preview/2666916/5/14?2&s=%7B%22size%22%3A144%2C%22text%22%3A%22Developer%20Experience%22%2C%22retina%22%3Atrue%7D) ![image](https://d3ui957tjb5bqd.cloudfront.net/op/font-preview/2666916/5/14?2&s=%7B%22size%22%3A144%2C%22text%22%3A%22%26%22%2C%22retina%22%3Atrue%7D) ![image](https://d3ui957tjb5bqd.cloudfront.net/op/font-preview/2666916/5/14?2&s=%7B%22size%22%3A144%2C%22text%22%3A%22Developer%20Tooling%22%2C%22retina%22%3Atrue%7D) [![img](https://d3ui957tjb5bqd.cloudfront.net/op/font-preview/2772760/3/14?2&s=%7B%22size%22%3A72%2C%22text%22%3A%22by%20Ahmad%20Awais%22%7D)](https://twitter.com/mrahmadawais/) .footCenter.bio[β οΈ Press f to go full-screen.] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #7F16F2, #1E1D40) .column_t2.font10em[ <a class="imgLnk" href="https://twitter.com/mrahmadawais/"> <img class="w100p" src="img/aa.jpg" /> </a> ] .column_t2[.vmiddle.pushfront[ #### π I'm # Ahmad Awais --- π₯ Open Source Developer Advocate π WordPress Core Dev (Full Stack) π¨βπ» EE-CS Engineer turned Emojineer --- .bio[Rants on Twitter [@MrAhmadAwais β](https://twitter.com/mrahmadawais/)] .bio.smLnk[[FOSS GitHub](https://github.com/ahmadawais) | [AhmadAwais.com](https://AhmadAwais.com/) | [LinkedIn](https://www.linkedin.com/in/mrahmadawais/)] ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #875EFF, #28A1F2) .column_t2[.vmiddle.pushfront.padRight[ #### π¦ Follow # .noLnk[[@MrAhmadAwais](https://twitter.com/mrahmadawais/)] --- π₯ Development Hot Tips π€£ Developer jokes/rantsβ you name it π― SuperCaliFragilisticExpialidocious! --- .bio.smLnk[MOAR: [FOSS GitHub](https://github.com/ahmadawais) | [AhmadAwais.com](https://AhmadAwais.com/) | [LinkedIn](https://www.linkedin.com/in/mrahmadawais/)] ]] .column_t2.font10em[ <a class="imgLnk" href="https://twitter.com/mrahmadawais/"> <img class="w100p" src="img/twtaa.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #373277, #4D43D1) .column_t2[.vmiddle.pushfront.padRight[ ## π¨βπ« VSCode.pro --- After ten years of Sublime, in 2017 I completely switched over to this new open source code editor called Visual Studio Code. I couldn't be happier. --- β JavaScript Based Open Source Editor π I was able to contribute π¨βπ» to VSCode π [Shades of purple β£](https://marketplace.visualstudio.com/items?itemName=ahmadawais.shades-of-purple) my first code editor theme is used by over 10,000 developers in .smLnk[[VSCode](https://marketplace.visualstudio.com/items?itemName=ahmadawais.shades-of-purple)], .smLnk[[iTerm2](https://github.com/ahmadawais/shades-of-purple-iterm2)], .smLnk[[Hyper](https://github.com/ahmadawais/shades-of-purple-hyper)], .smLnk[[Slack](https://github.com/ahmadawais/shades-of-purple-slack)], .smLnk[[Alfred](https://github.com/ahmadawais/shades-of-purple-alfred)], .smLnk[[Highlight.js](https://github.com/ahmadawais/Shades-of-Purple-HighlightJS)], etc. --- π Sign up to [become a VSCode Power User β](https://VSCode.pro/) --- ]] .column_t2.font10em[ <a class="imgLnk" href="https://VSCode.pro/"> <img class="w100p pulseImg" src="img/vspro.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, tomato, gold) .column_t2.font10em[ <i class="pulse twa twa-2x twa-drum-with-drumsticks" style="position:absolute; bottom:2rem; left:7rem; margin:0 !important;"></i> ] .column_t2[.vmiddle.pushfront[ # Dev Experience --- Let's talk about **you; the DEVELOPER**. --- π Your **experience as a developer** π How can you improve your **dev-workflow** π And **developer tooling** to make you better β οΈ Press `f` to go full-screen ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #F2C54B, #E44E27) .column_t2[.vmiddle.pushfront.padRight[ # Dev Tooling --- **Developer Tooling** is important if you want to love what you do and do it more often at the same time. --- β Love what you do β Do it more often π― Sane automation ]] .column_t2.font10em[ <i class="pulse twa twa-2x twa-hammer-and-wrench" style="position:absolute; bottom:2rem; right:7rem; margin:0 !important;"></i> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #2C65FF, #C423FF) .column_t2[.vmiddle.pushfront.padRight[ ## π¦ create-guten-block --- A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins. --- π Downloaded 60,000+ times π¨βπ» Used by over 15,000 developers πΎ Over 1,000 projects depend on CGB --- π Star [create-guten-block β](https://AhmdA.ws/CreateGutenBlock) --- ]] .column_t2.font10em[ <a class="imgLnk" href="https://github.com/ahmadawais/create-guten-block"> <img class="w100p pulseImg" src="img/cgb.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #7F16F2, #1E1D40) .column_t2.font10em[ <a class="imgLnk" href="https://github.com/ahmadawais/create-guten-block"> <img class="w100p pulseImg" src="https://on.ahmda.ws/tBRl/c" /> </a> ] .column_t2[.vmiddle.pushfront[ ## .center[π¦ CGB Usage] --- ```shell # 1. Create the block plugin. npx create-guten-block my-block # 2. Browse the plugin. cd my-block # 3. Start compiling & Watching. npm start # 4. Build for production. npm run build ``` --- .center[π Star [create-guten-block β](https://github.com/ahmadawais/create-guten-block)] --- ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #7F16F2, #1E1D40) .column_t2.font10em[ <a class="imgLnk" href="https://github.com/ahmadawais/create-guten-block"> <img class="w100p pulseImg" src="https://on.ahmda.ws/tBRl/c" /> </a> ] .column_t2[.vmiddle.pushfront[ ## WHAT YOU GET --- βοΈ React, JSX, and ES6 syntax support ποΈ Dev/production build process is webpack based π Beyond ES6 i.e. `async/await`, object spread, etc π€ Auto-prefixed CSS, no need for `-webkit` prefixes π Bundled JS, CSS, and images for production π οΈ Hassle-free single dependency of `cgb-scripts` --- π Star [create-guten-block β](https://AhmdA.ws/CreateGutenBlock) --- ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #F81700, #00b0ff) .column_t2[.vmiddle.pushfront.padRight[ ## π― WPGulp --- An advanced & extensively documented Gulp WordPress boilerplate to help you kickstart a build-workflow for your WordPress plugins and themes. --- π Downloaded 110,000+ times π¨βπ» Used by over 20,000 developers πΎ About 3,000 projects depend on it --- π Star [WPGulp β](https://github.com/ahmadawais/WPGulp) --- ]] .column_t2.font10em[ <a class="imgLnk" href="https://github.com/ahmadawais/WPGulp"> <img class="w100p pulseImg" src="img/wpg.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #CA3534, #611014) .column_t2[.vmiddle.pushfront.padRight[ ## npm --- `npm` is the node package manager. --- β It's used for the JavaScript language π― It is the default package manager for Node.js ]] .column_t2.font10em[ <a class="imgLnk" href="https://www.npmjs.com/"> <img class="w100p pulseImg" src="img/npm.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #7F16F2, #1E1D40) .column_t2.font10em[ <a class="imgLnk" href="https://www.npmjs.com/"> <img class="w100p pulseImg" src="https://on.ahmda.ws/tCak/c" /> </a> ] .column_t2[.vmiddle.pushfront[ ## Publish NPM Packages --- β `npm init -y` β read [the docs](https://docs.npmjs.com/cli/init) π― `npm publish` β read [the docs](https://docs.npmjs.com/cli/publish) and a detailed article on [how to publish your package on npm](https://hackernoon.com/how-to-publish-your-package-on-npm-7fc1f5aae600) π€ `release-it` can automate GitHub tags, releases, and npm publishing. More on [release-it](https://github.com/webpro/release-it) ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #543D2D, #F88B0A) .column_t2[.vmiddle.pushfront.padRight[ ## Composer --- `composer` is a Dependency Manager. --- β It's used for the PHP π― Packagist is the main Composer repository. ]] .column_t2.font10em[ <a class="imgLnk" href="https://getcomposer.org/"> <img class="w100p pulseImg" src="img/composer.png" /> </a> ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #7F16F2, #1E1D40) .column_t2.font10em[ <a class="imgLnk" href="https://www.npmjs.com/"> <img class="w100p pulseImg" src="https://on.ahmda.ws/tBHO/c" /> </a> ] .column_t2[.vmiddle.pushfront[ ## Using Composer --- π€ Get started with Composer β read [the docs](https://getcomposer.org/doc/00-intro.md) β `composer init` β read [the docs](https://getcomposer.org/doc/03-cli.md#init) π― Publish packages on [Packagist](https://packagist.org/) π₯ Hot tip: [Using composer with Teams](https://twitter.com/MrAhmadAwais/status/1020023997172416512) ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #F5AE16, #F19021) .column_t2.font10em[ <i class="pulse twa twa-2x twa-face-with-monocle" style="position:absolute; bottom:2rem; left:7rem; margin:0 !important;"></i> ] .column_t2[.vmiddle.pushfront[ # What's NEXT? --- Let's build some sort of automation, RIGHT! --- β Most devs are well versed in `Gulp` β Many devs find `webpack` quite hard π‘ How about we combine `Gulp` and `webpack` ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bleft.png), linear-gradient(to bottom, #F5AE16, #F19021) .column_t2[.vmiddle.pushfront.padRight[ # Gulp + webpack --- **Mind blown?!** OK here's what we're going to do: --- π― Combine `WPGulp` with `create-guten-block` β Code modern JavaScript by using `webpack` β Keep handling everything else with `Gulp` π β π« β π β π β π€ β π β π§ β β ]] .column_t2.font10em[ <i class="pulse twa twa-2x twa-exploding-head" style="position:absolute; bottom:2rem; right:7rem; margin:0 !important;"></i> ] --- class: center, middle, bgGulp layout: false # Gulp Task for webpack -- <hr> Let's create a task inside of WPGulp's `gulpfile.js` to handle `webpack` JavaScript compiler. <hr> --- class: middle, bgGulp layout: false .left-column[ ### 1. Install Development Dependencies ] .right-column[ .space.sp1[] ```shell # TERMINAL # 1. Open your project root folder and run. npm i -D webpack webpack-cli gulp-util babel-preset-cgb babel-core ``` ] --- class: middle, bgGulp layout: false .left-column[ ### 1. Install Development Dependencies ### 2. Create a webpack config ] .right-column[ .space.sp2[] ```shell # TERMINAL # 2. Create a webpack config. touch webpack.config.js ``` ] --- class: middle, bgGulp layout: false .left-column[ ### 1. Install Development Dependencies ### 2. Create a webpack config ### 3. Declare Constants ] .right-column[ .space.sp3[] ```js // Inside gulpfile.js // #3. Define constants. const webpack = require( 'webpack' ); const gutil = require( 'gulp-util' ); const webpackConfig = require( './webpack.config' ); ``` ] --- class: middle, bgGulp layout: false .left-column[ ## 4. WRITE THE GULP TASK ] .right-column[ ```js // Inside gulpfile.js // JavaScript via webpack. gulp.task( 'webpackJS', callback => { webpack( webpackConfig, ( err, stats ) => { if ( err ) { throw new gutil.PluginError( 'webpack', err ); } gutil.log( '[webpack]', stats.toString({ colors: true, progress: true }) ); callback(); }); }); ``` ] --- class: middle, bgGulp layout: false .left-column[ ## 4. WRITE THE GULP TASK ##### 4.1 `'webpackJS'` task ] .right-column[ ```js // Inside gulpfile.js // JavaScript via webpack. * gulp.task( 'webpackJS', callback => { * webpack( webpackConfig, ( err, stats ) => { * if ( err ) { * throw new gutil.PluginError( 'webpack', err ); * } * gutil.log( * '[webpack]', * stats.toString({ * colors: true, * progress: true * }) * ); * callback(); * }); * }); ``` ] --- class: middle, bgGulp layout: false .left-column[ ## 4. WRITE THE GULP TASK ##### 4.1 `'webpackJS'` task ##### 4.2 `webpack` compiler ] .right-column[ ```js // Inside gulpfile.js // JavaScript via webpack. gulp.task( 'webpackJS', callback => { * webpack( webpackConfig, ( err, stats ) => { * if ( err ) { * throw new gutil.PluginError( 'webpack', err ); * } * gutil.log( * '[webpack]', * stats.toString({ * colors: true, * progress: true * }) * ); * callback(); * }); }); ``` ] --- class: middle, bgGulp layout: false .left-column[ ## 4. WRITE THE GULP TASK ##### 4.1 `'webpackJS'` task ##### 4.2 `webpack` compiler ##### 4.3 Error handling ] .right-column[ ```js // Inside gulpfile.js // JavaScript via webpack. gulp.task( 'webpackJS', callback => { webpack( webpackConfig, ( err, stats ) => { * if ( err ) { * throw new gutil.PluginError( 'webpack', err ); * } gutil.log( '[webpack]', stats.toString({ colors: true, progress: true }) ); callback(); }); }); ``` ] --- class: middle, bgGulp layout: false .left-column[ ## 4. WRITE THE GULP TASK ##### 4.1 `'webpackJS'` task ##### 4.2 `webpack` compiler ##### 4.3 Error handling ##### 4.3 `webpack` log ] .right-column[ ```js // Inside gulpfile.js // JavaScript via webpack. gulp.task( 'webpackJS', callback => { webpack( webpackConfig, ( err, stats ) => { if ( err ) { throw new gutil.PluginError( 'webpack', err ); } * gutil.log( * '[webpack]', * stats.toString({ * colors: true, * progress: true * }) * ); callback(); }); }); ``` ] --- class: center, middle, bgGradient layout: false # Configuration file for webpack <!-- class: center, middle, bgGradient --> <hr> -- π Copy paste the `webpack` [config of cgb-scripts](https://github.com/ahmadawais/create-guten-block/blob/master/packages/cgb-scripts/config/webpack.config.dev.js) to our `webpack.config.js` file. <hr> -- β Trim anything that doesn't handle JavaScript from our `webpack.config.js` file <hr> -- β Update the paths and we're good to go <hr> -- π Let's have a look --- class: middle, bgGoldTomato layout: false .left-column[ ### 1. Update Paths ] .right-column[ Add paths by looking at the [paths](https://github.com/ahmadawais/create-guten-block/blob/master/packages/cgb-scripts/config/paths.js) file. ```js // FILE: webpack.config.js const fs = require( 'fs' ); const path = require( 'path' ); * // Make sure any symlinks in the project folder are resolved: * const theDir = fs.realpathSync( process.cwd() ); * const resolvePath = relPath => path.resolve( theDir, relPath ); ``` ] --- class: middle, bgGoldTomato layout: false .left-column[ ### 1. Update Paths ### 2. Add the Mode ] .right-column[ .space.sp1[] ```js // FILE: webpack.config.js // β¦ // Export configuration. module.exports = { * mode: 'development', devtool: 'source-map', ``` ] --- class: middle, bgGoldTomato layout: false .left-column[ ### 1. Update Paths ### 2. Add The Mode ### 3. Update Entry/Output ] .right-column[ ```js // FILE: webpack.config.js // β¦ // Export configuration. module.exports = { mode: 'development', devtool: 'source-map', entry: { * 'main.min': './assets/js/src/index.js' // 'name' : 'path/file.ext'. }, output: { pathinfo: true, * path: resolvePath( './assets/js/build/' ), // The dist folder. filename: '[name].js' // [name] = './assets/js/index.build' as defined above. }, ``` ] --- class: middle, bgGoldTomato layout: false .left-column[ ### 1. Update Paths ### 2. Add The Mode ### 3. Update Entry/Output ### 4. Add New Externals ] .right-column[ .space.sp2[] ```js // FILE: webpack.config.js // β¦ // Add externals. externals: { * wpObj: 'wpObj', * gtag: 'gtag', * Intercom: 'Intercom', * jquery: 'jQuery' } ``` ] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #F5AE16, #F19021) .column_t2.font10em[ <img class="w100p" src="img/gulpack.gif" /> ] .column_t2[.vmiddle.pushfront[ # Gulp + webpack --- **Mind blown?!** Here's what we've accomplished: --- π― JavaScript is being handled by `webpack` β Everything else is still being handled by `WPGulp` β We can now use modern JavaScript features, npm Modules, async/await, Object/Array spreads, etc. π€ β π β π§ β π€ β π€« β π β π€ ]] --- class: split-50 nopadding bkgpos_00 background-image: url(img/bright.png), linear-gradient(to bottom, #292F33, #654500) .column_t2.font10em[ <i class="pulse twa twa-2x twa-smiling-face-with-sunglasses" style="position:absolute; bottom:2rem; left:7rem; margin:0 !important;"></i> ] .column_t2[.vmiddle.pushfront[ .center[ # Questions?! --- .bio[Follow Ahmad on Twitter [@MrAhmadAwais β](https://twitter.com/mrahmadawais/)] --- .bio.smLnk[[FOSS GitHub](https://github.com/ahmadawais) | [AhmadAwais.com](https://AhmadAwais.com/) | [LinkedIn](https://www.linkedin.com/in/mrahmadawais/)] ] ]]