Linux command
webpack 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Build the project
webpack
Build with a specific configuration file
webpack --config [webpack.config.js]
Build for production
webpack --mode production
Build for development
webpack --mode development
Watch for changes
webpack --watch
Specify output directory
webpack --output-path [path/to/dist]
Start the development server
webpack serve
Show build statistics
webpack --stats verbose
说明
webpack is a static module bundler for modern JavaScript applications. It builds a dependency graph from entry points and bundles modules into optimized output files for browsers. The CLI is provided by webpack-cli and wraps webpack's configuration options. Most options can be specified via command line or in webpack.config.js. CLI options override configuration file settings. webpack supports code splitting, lazy loading, tree shaking, and various loaders and plugins for processing different file types (CSS, images, TypeScript, etc.).
参数
- build, bundle, b
- Run webpack to bundle the project (default command).
- serve, server, s
- Run webpack dev server.
- watch, w
- Run webpack and watch for file changes.
- init, create, c
- Initialize a new webpack project.
- info, i
- Output information about your system.
- configtest, t
- Validate a webpack configuration file.
- -c, --config _file_
- Path to webpack configuration file.
- --config-name _name_
- Name of the configuration to use.
- -m, --merge
- Merge multiple configurations.
- --mode _mode_
- Set mode: production, development, or none.
- -o, --output-path _path_
- Output directory (absolute path).
- -w, --watch
- Watch mode, rebuild on file change.
- --env _value_
- Environment variables passed to config function.
- --stats _preset_
- Stats output level: errors-only, minimal, normal, verbose.
- -v, --version
- Display version information.
- -h, --help
- Display help message.
FAQ
What is the webpack command used for?
webpack is a static module bundler for modern JavaScript applications. It builds a dependency graph from entry points and bundles modules into optimized output files for browsers. The CLI is provided by webpack-cli and wraps webpack's configuration options. Most options can be specified via command line or in webpack.config.js. CLI options override configuration file settings. webpack supports code splitting, lazy loading, tree shaking, and various loaders and plugins for processing different file types (CSS, images, TypeScript, etc.).
How do I run a basic webpack example?
Run `webpack` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does build, bundle, b do in webpack?
Run webpack to bundle the project (default command).