├── .gitignore ├── LICENSE ├── README.md ├── package.json ├── presentation.md ├── presentation.pdf ├── src ├── cat.png ├── index.js ├── miau.mp3 └── style.styl └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | dist 3 | node_modules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2017 Aarni Koskela 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Demystifying Webpack 2 | 3 | This is the presentation and code from 4 | the Demystifying Webpack presentation I held 5 | at Turku <3 Frontend on 26th April 2017. 6 | 7 | The presentation is available in PDF and 8 | Markdown formats. 9 | 10 | * [presentation.pdf](./presentation.pdf) 11 | * [presentation.md](./presentation.md) 12 | 13 | The commits in the repository reflect the 14 | evolution of the code as it was written during 15 | the presentation. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-demystified", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "scripts": { 7 | "dev": "webpack-dev-server" 8 | }, 9 | "dependencies": { 10 | "babel-core": "^6.24.1", 11 | "babel-loader": "^7.0.0", 12 | "babel-preset-env": "^1.4.0", 13 | "babel-preset-react": "^6.24.1", 14 | "css-loader": "^0.28.0", 15 | "file-loader": "^0.11.1", 16 | "react": "^15.5.4", 17 | "react-dom": "^15.5.4", 18 | "style-loader": "^0.16.1", 19 | "stylus": "^0.54.5", 20 | "stylus-loader": "^3.0.1", 21 | "url-loader": "^0.5.8", 22 | "webpack": "^2.4.1" 23 | }, 24 | "devDependencies": { 25 | "webpack-dev-server": "^2.4.4" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /presentation.md: -------------------------------------------------------------------------------- 1 | # Demystifying Webpack 2 | Turku ❤ Frontend 3 | 26 April 2017 4 | 5 | ## Hello! 👋 6 | * I'm Aarni Koskela (@akx) 7 | * I've been writing code since I was about 6 years old 8 | * ... and doing web stuff since IE 6 was a Good Thing 9 | * Now working at Valohai on a cutting-edge machine learning infrastructure SaaS (that's a mouthful) 10 | 11 | 12 | ## A Disclaimer 13 | 14 | * I'm not going to cover all the more advanced features Webpack supports in this presentation. 15 | * Juho Vepsäläinen (@bebraw) has a book and a presentation on that! https://leanpub.com/survivejs-webpack 16 | 17 | ## And by the way 18 | 19 | * Please feel free to interrupt at any time! 20 | 21 | ## So, what is Webpack anyway? 22 | 23 | Webpack is a module bundler (like its predecessor Browserify) 24 | 25 | It . . . 26 | 27 | * takes one or more files (primarily, but not only, JavaScript) 28 | * transforms them 29 | * produces one or more bundle files (again, primarily but not necessarily only JavaScript) 30 | 31 | ## Why Webpack? 32 | 33 | * If you want to use ES6/JSX syntax in all browsers (e.g. using Babel or Bublé) 34 | * If you want to optimize and minify your code before delivering it to clients (built-in!) 35 | * If you want nicer encapsulation and componentization (CSS within your bundle, for instance) 36 | * If you want live code reloading (lovely for development) 37 | 38 | ## But isn't Webpack impossible to configure? 39 | 40 | * That's the myth! 41 | * Webpack is pretty easy to get going with (with a basic configuration) 42 | * Of course, more complex configurations (splitting, per-module hot reloading, ...) get more complicated 43 | 44 | ## Let's do this! 45 | 46 | Let's set up a simple SPA (single page application) from scratch with 47 | 48 | * Webpack 49 | * React 50 | * Stylus-based stylesheets (could just as well be SASS/SCSS or LESS) 51 | * Photos of cats, because of course :) 52 | 53 | (in reality, you might want to start something like this using create-react-app, but for the sake of practice...) 54 | 55 | ## First: installing stuff! 56 | 57 | The packages we need are: 58 | * webpack (duh) 59 | * react (React itself) 60 | * react-dom (React's browser interface) 61 | * file-loader (allows `require`ing binary files) 62 | * style-loader (injects