### Install webpack-cli Source: https://github.com/webpack/webpack-cli/blob/main/packages/README.md Use this command to perform a standalone installation of the webpack-cli package. ```shell npm install webpack-cli ``` -------------------------------- ### Install webpack-cli with pnpm Source: https://github.com/webpack/webpack-cli/blob/main/README.md Use this command to install the webpack CLI as a development dependency using pnpm. ```bash pnpm add --D webpack-cli ``` -------------------------------- ### Install webpack-cli with npm Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md Use this command to install webpack-cli as a development dependency using npm. ```bash npm install --save-dev webpack-cli ``` -------------------------------- ### Install webpack-cli with yarn Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md Use this command to install webpack-cli as a development dependency using yarn. ```bash yarn add webpack-cli --dev ``` -------------------------------- ### Conditional package check in parser Source: https://github.com/webpack/webpack-cli/wiki/Init-Feature-Design-Overview-[OLD] Example of the logic used in the parser to handle multiple packages during the initialization process. ```js if(pkg && opts) {/* we still got packages left, but we've done some work already */ } ``` -------------------------------- ### Install shell completion package Source: https://github.com/webpack/webpack-cli/blob/main/README.md Install the optional @bomb.sh/tab package to enable shell completion for webpack commands. ```sh npm install --save-dev @bomb.sh/tab ``` -------------------------------- ### Use shell tab completion Source: https://github.com/webpack/webpack-cli/blob/main/README.md Examples of how to use the Tab key to complete webpack commands, modes, and options after restarting your shell. ```sh webpack b # webpack build webpack build --mode= # development, production, none webpack serve --his # webpack serve --history-api-fallback ``` -------------------------------- ### Basic usage of create-webpack-app Source: https://github.com/webpack/webpack-cli/blob/main/packages/create-webpack-app/README.md The standard command to invoke the CLI tool. ```bash npx create-webpack-app [command] [options] ``` -------------------------------- ### Run webpack-cli init with an addon Source: https://github.com/webpack/webpack-cli/wiki/Init-Feature-Design-Overview-[OLD] Command to test the init feature by specifying a webpack-addons package. ```bash webpack-cli --init webpack-addons-ylvis ``` -------------------------------- ### Initialize a new webpack project Source: https://github.com/webpack/webpack-cli/blob/main/README.md Run this command to create a fresh webpack project. You will be prompted to select features like scss, typescript, or PWA support. ```sh npx create-webpack-app init ``` -------------------------------- ### Display help information Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md Commands to display basic or verbose help information for webpack-cli. ```bash npx webpack-cli --help ``` ```bash npx webpack-cli --help=verbose ``` ```bash npx webpack-cli --help verbose ``` -------------------------------- ### Generate project from a template Source: https://github.com/webpack/webpack-cli/blob/main/packages/create-webpack-app/README.md Use a specific template name to scaffold the project. ```bash npx create-webpack-app --template ``` -------------------------------- ### Available webpack-cli options Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md Configuration options and flags available for webpack-cli commands. ```text Options: -c, --config Provide path to one or more webpack configuration files to process, e.g. "./webpack.config.js". --config-name Name(s) of particular configuration(s) to use if configuration file exports an array of multiple configurations. -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment variables passed to the configuration when it is a function, e.g. "myvar" or "myvar=myval". --config-node-env Sets process.env.NODE_ENV to the specified value for access within the configuration. --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [pathToJsonFile] Prints result as JSON or store it in a file. --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack. -d, --devtool A developer tool to enhance debugging (false | eval | [inline-|hidden-|eval-][nosources-][cheap-[module-]]source-map). --no-devtool Negative 'devtool' option. --entry A module that is loaded upon startup. Only the last one is exported. -e, --extends Path to the configuration to be extended (only works when using webpack-cli). --mode Enable production optimizations or development hints. --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. --no-color Disable colors on console. -v, --version Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. -h, --help [verbose] Display help for commands and options. ``` -------------------------------- ### Generate default template Source: https://github.com/webpack/webpack-cli/blob/main/packages/create-webpack-app/README.md Run the generator with default settings. ```bash npx create-webpack-app ``` -------------------------------- ### Basic webpack-cli usage Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md The standard format for interacting with webpack-cli. If no command is provided, the bundle command is used by default. ```bash npx webpack-cli [command] [options] ``` -------------------------------- ### Available webpack-cli commands Source: https://github.com/webpack/webpack-cli/blob/main/packages/webpack-cli/README.md A list of commands supported by webpack-cli for building, testing, and serving applications. ```text build|bundle|b [entries...] [options] Run webpack (default command, can be omitted). complete [shell] Generate shell completion scripts. configtest|t [config-path] Validate a webpack configuration. help|h [command] [option] Display help for commands and options. info|i [options] Outputs information about your system. serve|server|s [entries...] [options] Run the webpack dev server and watch for source file changes while serving. version|v [options] Output the version number of 'webpack', 'webpack-cli' and 'webpack-dev-server' and commands. watch|w [entries...] [options] Run webpack and watch for files changes. ``` -------------------------------- ### Generate in a specified path Source: https://github.com/webpack/webpack-cli/blob/main/packages/create-webpack-app/README.md Specify a custom directory path for the generated project. ```bash npx create-webpack-app [generation-path] ``` -------------------------------- ### Generate with default answers Source: https://github.com/webpack/webpack-cli/blob/main/packages/create-webpack-app/README.md Use the force flag to skip interactive prompts and use default answers. ```bash npx create-webpack-app -f ``` ```bash npx create-webpack-app --force ``` -------------------------------- ### Configure shell completion scripts Source: https://github.com/webpack/webpack-cli/blob/main/README.md Load the completion script for your specific shell to enable tab completion for webpack commands and options. ```sh # zsh echo 'source <(webpack complete zsh)' >> ~/.zshrc # bash echo 'source <(webpack complete bash)' >> ~/.bashrc # fish webpack complete fish > ~/.config/fish/completions/webpack.fish # powershell webpack complete powershell > ~/.webpack-completion.ps1 echo '. ~/.webpack-completion.ps1' >> $PROFILE ``` -------------------------------- ### Define folder structure Source: https://github.com/webpack/webpack-cli/wiki/Meeting-notes:-2.2.2016 Proposed directory structure for the webpack-cli project, organizing functionality into modules like migrations, transformations, initialization, and validation. ```text / |- migrate: JS->AST->JS |-- ... |- transformations |-- loaders |-- utils |-- ... |- init: Inquirer + AST -> JS |-- basicSetup (entry, output, loaders: css, scss, less, etc) |-- FrameworksSetup |-- environmentSetup (prod/dev) |-- ... |- parser: JS<->AST |- validation (for init and migrate) |-- ... |- schema |- compiler (functionality of webpack cli) |-- ... |- utils |-- ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.