bruce campbell
@eatrocks
https://webpack.js.org/
me - just now
generic: discrete chunk of functionality
webpack: any file referenced by
import thingMaker from './thing-inator.js'
import styles from './my.css'
import logo from './company-logo.png'
...
Text
you said it was a code bundler not a code splitter...
strategically split your resources into more than 1 bundle
...instead of producing just 1 bundle per resource type
admin area
main site
dead code removal
live code import
webpack 2: https://webpack.js.org/configuration/
webpack 1: https://webpack.github.io/docs/
webpack processes code by following your imports
you give it the "entry" point
gulp.src('./app/**/*.js')
so instead of giving it glob patterns...
{
entry: './app/index.js',
...
};
output tells webpack where to write the processed files (a.k.a. bundles)
{
...
output: {
filename: 'app.js',
path: 'dist'
}
}
a loader tells webpack how to load (or process) a particular type of file...
think "tasks" in other build systems
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
{
test: /\.(png|jpe?g|gif|svg|mp3|mpe?g)$/,
loader: "file-loader",
...
}
allow us to extend the functionality of webpack
UglifyJsPlugin: minifies javascript
plugins: [
new UglifyJsPlugin({...}),
...
],
module.exports = {
entry: './app/index.js',
...
};
UglifyJS
webpack 2: https://webpack.js.org/
loaders: https://webpack.js.org/loaders/
plugins: https://webpack.js.org/plugins/
code splitting: https://webpack.js.org/guides/code-splitting/
tree shaking: https://webpack.js.org/guides/tree-shaking/
awesome webpack: https://github.com/webpack-contrib/awesome-webpack#webpack-plugins
webpack the confusing parts: https://medium.com/@rajaraodv/webpack-the-confusing-parts-58712f8fcad9
using webpack for production javascript applications: https://egghead.io/courses/using-webpack-for-production-javascript-applications