webpack-demo
webpack-demo copied to clipboard
webpack 4 config. demo :gear:
Webpack 4 Demo · Legato :notes:
Demo project to start using and experiment with Webpack 4
Start
Restore dependencies and start development server:
yarn && yarn dev
Check your browser console at localhost:8080
Features
entry/outputcustom config.- chunk splitting (
app|vendors) - html creation: html-webpack-plugin
- copying files: copy-webpack-plugin
- webpack-dev-server
- Sass support
- Hot Module Replacement
Webpack
Install webpack
yarn add webpack webpack-cli --dev
More
This project started with Webpack 4 in beta version:
# add webpack 4 (currently on 4.0.0-beta.2)
yarn add webpack@next webpack-cli --dev
Zero Config (#0CJS)
Entry / Output
No need for explicit specify entry and output properties in the webpack configuration.
In Webpack 4 those fields are defaulted to:
{
"entry": "./src",
"output": "./dist"
}
Mode
Webpack mode reduce the required configuration for an useful build:
development: this mode provide useful error messages and is optimized for speed (unminified bundle)production: enables optimizations out of the box (scope hoisting, tree shaking, minification, etc.)
webpack --mode production
There is also another hidden none mode which disables everything (available only inside the configuration object).
Changes
- Dropped Node.js 4 support. Therefore, more benefits from ES6 features (optimizations from V8).
- Sets of defaults with production and development modes.
- Changes on plugins (Some actives depending on mode.
CommonsChunkPluginwas removed) - Optimizations, performance boost and many more...
- Read changeset of Webpack v4.0.0
Articles
- :rocket: webpack 4 beta — try it today! :rocket:
- webpack 4: mode and optimization
- webpack 4: import() and CommonJs
- webpack 4: Code Splitting, chunk graph and the splitChunks optimization
- webpack 4: released today!! :sparkles:
- release notes & changelog
License
MIT © Carloluis