HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

webpack — Bundle a web project's js files and other assets into a single output file. More information: <https

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandfilesandbundlecliwebwebpackproject

Problem

How to use the webpack command: Bundle a web project's js files and other assets into a single output file. More information: <https://webpack.js.org/api/cli/>.

Solution

webpack — Bundle a web project's js files and other assets into a single output file. More information: <https://webpack.js.org/api/cli/>.

Create a single output file from an entry point file:
webpack {{app.js}} {{bundle.js}}


Load CSS files too from the JavaScript file (this uses the CSS loader for CSS files):
webpack {{app.js}} {{bundle.js}} --module-bind '{{css=css}}'


Pass a configuration file (with e.g. the entry script and the output filename) and show compilation progress:
webpack {{[-c|--config]}} {{webpack.config.js}} --progress


Automatically recompile on changes to project files:
webpack {{[-w|--watch]}} {{app.js}} {{bundle.js}}

Code Snippets

Create a single output file from an entry point file

webpack {{app.js}} {{bundle.js}}

Load CSS files too from the JavaScript file (this uses the CSS loader for CSS files)

webpack {{app.js}} {{bundle.js}} --module-bind '{{css=css}}'

Pass a configuration file (with e.g. the entry script and the output filename) and show compilation progress

webpack {{[-c|--config]}} {{webpack.config.js}} --progress

Automatically recompile on changes to project files

webpack {{[-w|--watch]}} {{app.js}} {{bundle.js}}

Context

tldr-pages: common/webpack

Revisions (0)

No revisions yet.