Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webpack/webpack-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: webpack-cli@4.6.0
Choose a base ref
...
head repository: webpack/webpack-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: webpack-cli@4.7.0
Choose a head ref
Loading
Showing 314 changed files with 21,435 additions and 7,961 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -31,11 +31,7 @@ module.exports = {
},
},
files: ['**/*.ts'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
],
extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: daily
time: '04:00'
timezone: Europe/Berlin
open-pull-requests-limit: 10
versioning-strategy: lockfile-only
10 changes: 7 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ jobs:
run: yarn lint

build:
name: Tests and Coverage - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
name: Tests and Coverage - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}, DevServer ${{ matrix.dev-server-version }}

runs-on: ${{ matrix.os }}

@@ -56,6 +56,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.x, 12.x, 14.x]
webpack-version: [4, latest]
dev-server-version: [latest, next]

steps:
- uses: actions/checkout@v2
@@ -74,16 +75,19 @@ jobs:
path: |
node_modules
*/*/node_modules
key: b-${{ runner.os }}-${{ matrix.webpack-version }}-yarn-${{ hashFiles('**/yarn.lock', './yarn.lock') }}
key: c-${{ runner.os }}-${{ matrix.webpack-version }}-yarn-${{ hashFiles('**/yarn.lock', './yarn.lock') }}
restore-keys: |
b-${{ runner.os }}-${{ matrix.webpack-version }}-yarn-
c-${{ runner.os }}-${{ matrix.webpack-version }}-yarn-
- name: Install dependencies
run: yarn

- name: Install webpack ${{ matrix.webpack-version }}
run: yarn add -W webpack@${{ matrix.webpack-version }}

- name: Install webpack-dev-server ${{ matrix.webpack-version }}
run: yarn add -W webpack-dev-server@${{ matrix.dev-server-version }}

- name: Prepare environment for tests
run: yarn build:ci

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ test/**/node_modules
# Lock files
test/**/yarn.lock
test/**/package-json.lock
!test/api/**/yarn.lock
!test/api/**/package-lock.json

# npm-debug log
npm-debug.*
@@ -39,6 +41,7 @@ lerna-debug.log

# package-lock file
package-lock.json
!test/api/**/package-lock.json

junit.xml

1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
18 changes: 9 additions & 9 deletions INIT.md
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ webpack-cli init --force
**To scaffold in a specified path**

```bash
webpack-cli init [path]
webpack-cli init [generation-path]
```

**To scaffold specified template**
@@ -72,18 +72,18 @@ webpack-cli init --template <template-name>
This enables webpack to parse [`ES2015`](https://babeljs.io/learn-es2015/) code or Typescript code as per choice.

2. `Which of the following CSS solutions do you want to use?`

> _Property/key resolved: [module.rules](https://webpack.js.org/configuration/module/#module-rules) (for .css files)_
If you use any sort of style in your project, such as [`.css`](https://developer.mozilla.org/en-US/docs/Web/CSS) you will need to select this here. If you don't use CSS, answer `none`.

3. `Do you want to use webpack-dev-server?`
2. `Do you want to use webpack-dev-server?`

> _Property/key resolved: [module.rules](https://webpack.js.org/configuration/dev-server/)_
Adds a development server to serve webpack bundles and hence make development faster.

4. `Do you want to simplify the creation of HTML files for your bundle?`
3. `Do you want to simplify the creation of HTML files for your bundle?`

Adds `html-webpack-plugin` that simplifies creation of HTML files to serve your bundles.

4. `Which of the following CSS solutions do you want to use?`

> _Property/key resolved: [module.rules](https://webpack.js.org/configuration/module/#module-rules) (for .css files)_
If you use any sort of style in your project, such as [`.css`](https://developer.mozilla.org/en-US/docs/Web/CSS) you will need to select this here. If you don't use CSS, answer `none`.
21 changes: 16 additions & 5 deletions OPTIONS.md
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ Options:
--no-bail Negative 'bail' option.
--cache Enable in memory caching. Disable caching.
--no-cache Negative 'cache' option.
--cache-max-generations <value> Number of generations unused cache entries stay in memory cache at minimum (1 = may be removed after unused for a single compilation, ..., Infinity: kept forever).
--cache-type <value> In memory caching. Filesystem caching.
--cache-cache-directory <value> Base directory for the cache (defaults to node_modules/.cache/webpack).
--cache-cache-location <value> Locations for the cache (defaults to cacheDirectory / name).
@@ -31,6 +32,8 @@ Options:
--cache-immutable-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable.
--cache-managed-paths <value...> A path to a managed directory (usually a node_modules directory).
--cache-managed-paths-reset Clear all items provided in configuration. List of paths that are managed by a package manager and can be trusted to not be modified otherwise.
--cache-max-age <value> Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds).
--cache-max-memory-generations <value> Number of generations unused cache entries stay in memory cache at minimum (0 = no memory cache used, 1 = may be removed after unused for a single compilation, ..., Infinity: kept forever). Cache entries will be deserialized from disk when removed from memory cache.
--cache-name <value> Name for the cache. Different names will lead to different coexisting caches.
--cache-store <value> When to store data to the filesystem. (pack: Store data when compiler is idle in a single file).
--cache-version <value> Version of the cache data. Different versions won't allow to reuse the cache and override existing content. Update the version when config changed in a way which doesn't allow to reuse cache. This will invalidate the cache.
@@ -85,6 +88,10 @@ Options:
--ignore-warnings-message <value...> A RegExp to select the warning message.
--ignore-warnings-module <value...> A RegExp to select the origin module for the warning.
--ignore-warnings-reset Clear all items provided in configuration. Ignore specific warnings.
--infrastructure-logging-append-only Only appends lines to the output. Avoids updating existing output e. g. for status messages. This option is only used when no custom console is provided.
--no-infrastructure-logging-append-only Negative 'infrastructure-logging-append-only' option.
--infrastructure-logging-colors Enables/Disables colorful output. This option is only used when no custom console is provided.
--no-infrastructure-logging-colors Negative 'infrastructure-logging-colors' option.
--infrastructure-logging-debug [value...] Enable/Disable debug logging for all loggers. Enable debug logging for specific loggers.
--no-infrastructure-logging-debug Negative 'infrastructure-logging-debug' option.
--infrastructure-logging-debug-reset Clear all items provided in configuration. Enable debug logging for specific loggers.
@@ -103,12 +110,14 @@ Options:
--module-generator-asset-emit Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR.
--no-module-generator-asset-emit Negative 'module-generator-asset-emit' option.
--module-generator-asset-filename <value> Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.
--module-generator-asset-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
--module-generator-asset-inline-data-url-encoding <value> Asset encoding (defaults to base64).
--no-module-generator-asset-inline-data-url-encoding Negative 'module-generator-asset-inline-data-url-encoding' option.
--module-generator-asset-inline-data-url-mimetype <value> Asset mimetype (getting from file extension by default).
--module-generator-asset-resource-emit Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR.
--no-module-generator-asset-resource-emit Negative 'module-generator-asset-resource-emit' option.
--module-generator-asset-resource-filename <value> Specifies the filename template of output files on disk. You must **not** specify an absolute path here, but the path may contain folders separated by '/'! The specified path is joined with the value of the 'output.path' option to determine the location on disk.
--module-generator-asset-resource-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
--module-no-parse <value...> A regular expression, when matched the module is not parsed. An absolute path, when the module starts with this path it is not parsed.
--module-no-parse-reset Clear all items provided in configuration. Don't parse files matching. It's matched against the full resolved request.
--module-parser-asset-data-url-condition-max-size <value> Maximum size of asset that should be inline as modules. Default: 8kb.
@@ -534,7 +543,7 @@ Options:
-o, --output-path <value> Output location of the file generated by webpack e.g. ./dist/.
--output-pathinfo [value] Include comments with information about the modules.
--no-output-pathinfo Negative 'output-pathinfo' option.
--output-public-path <value> The `publicPath` specifies the public URL address of the output files when referenced in a browser.
--output-public-path <value> The 'publicPath' specifies the public URL address of the output files when referenced in a browser.
--output-script-type <value> This option enables loading async chunks via a custom script type, such as script type="module".
--no-output-script-type Negative 'output-script-type' option.
--output-source-map-filename <value> The filename of the SourceMaps for the JavaScript files. They are inside the 'output.path' directory.
@@ -774,6 +783,8 @@ Options:
--no-stats-group-modules-by-layer Negative 'stats-group-modules-by-layer' option.
--stats-group-modules-by-path Group modules by their path.
--no-stats-group-modules-by-path Negative 'stats-group-modules-by-path' option.
--stats-group-modules-by-type Group modules by their type.
--no-stats-group-modules-by-type Negative 'stats-group-modules-by-type' option.
--stats-hash Add the hash of the compilation.
--no-stats-hash Negative 'stats-hash' option.
--stats-ids Add ids.
@@ -858,11 +869,11 @@ Commands:
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.
init|c [generation-path] [options] Initialize a new webpack project.
loader|l [output-path] Scaffold a loader.
init|create|new|c|n [generation-path] [options] Initialize a new webpack project.
loader|l [output-path] [options] Scaffold a loader.
migrate|m <config-path> [new-config-path] Migrate a configuration to a new version.
plugin|p [output-path] Scaffold a plugin.
serve|s [entries...] [options] Run the webpack dev server.
plugin|p [output-path] [options] Scaffold a plugin.
serve|server|s [entries...] [options] Run the webpack dev server.
version|v [commands...] 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.
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
- [Commands](#commands)
- [Utilities](#utilities)
- [Getting started](#getting-started)
- [webpack CLI Scaffolds](#webpack-cli-scaffolds)
- [Exit codes and their meanings](#exit-codes-and-their-meanings)
- [Contributing and Internal Documentation](#contributing-and-internal-documentation)
- [Open Collective](#open-collective)
@@ -58,12 +57,12 @@ Thus, webpack CLI provides different commands for many common tasks.
- `build|bundle|b [entries...] [options]` - Run webpack (default command, can be omitted).
- [`configtest|t [config-path]`](./packages/configtest/README.md#webpack-cli-configtest) - Validate a webpack configuration.
- `help|h [command] [option]` - Display help for commands and options.
- [`init|c [generation-path] [options]`](./INIT.md#webpack-cli-init) - Create a new webpack project.
- [`init|create|new|c|n [generation-path] [options]`](./INIT.md#webpack-cli-init) - Create a new webpack project.
- [`info|i [options]`](./packages/info/README.md#webpack-cli-info) - Returns information related to the local environment.
- [`migrate|m <config-path> [new-config-path]`](https://www.npmjs.com/package/@webpack-cli/migrate) - Migrate project from one version to another.
- [`plugin|p [output-path]`](./packages/generators#generators) - Initiate new plugin project.
- [`loader|l [output-path]`](./packages/generators#generators) - Initiate new loader project.
- [`serve|s [entries...] [options]`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading.
- [`plugin|p [output-path] [options]`](./packages/generators#generators) - Initiate new plugin project.
- [`loader|l [output-path] [options]`](./packages/generators#generators) - Initiate new loader project.
- [`serve|server|s [entries...] [options]`](./packages/serve/README.md#webpack-cli-serve) - Use webpack with a development server that provides live reloading.
- `version|v [commands...]` - Output the version number of `webpack`, `webpack-cli`, `webpack-dev-server`, and commands
- `watch|w [entries...] [options]` - Run webpack and watch for files changes.

@@ -84,12 +83,6 @@ npx webpack-cli init

You will be prompted for some questions about what how you want to generate your config file when running the `init` command so webpack CLI can provide the best fitting configuration.

## webpack CLI Scaffolds

With v3 of webpack CLI, we introduced scaffolding as an integral part of the CLI. Our goal is to simplify the creation of webpack configurations for different purposes. Additionally, sharing such solutions with the community is beneficial and with webpack, we want to allow this. We provide `webpack-scaffold` as a utility suite for creating these scaffolds. It contains functions that could be of use for creating a scaffold yourself.

You can read more about [Scaffolding](https://webpack.js.org/guides/scaffolding), learn [How to compose a webpack-scaffold?](https://webpack.js.org/contribute/writing-a-scaffold) or generate one with [webpack-scaffold-starter](https://github.com/rishabh3112/webpack-scaffold-starter).

## Exit codes and their meanings

| Exit Code | Description |
2 changes: 1 addition & 1 deletion SERVE-OPTIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```
Usage: webpack serve|s [entries...] [options]
Usage: webpack serve|server|s [entries...] [options]
Run the webpack dev server.
6 changes: 0 additions & 6 deletions husky.config.js

This file was deleted.

6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -8,11 +8,13 @@ module.exports = {
testPathIgnorePatterns: ignorePattern,
testEnvironment: 'node',
collectCoverage: true,
coverageReporters: ['none'],
coverageDirectory: '.nyc_output',
coverageReporters: ['json'],
coveragePathIgnorePatterns: ['<rootDir>/test/'],
transform: {
'^.+\\.(ts)?$': 'ts-jest',
},
testRegex: ['/__tests__/.*\\.(test.js|test.ts)$', '/test/.*\\.(test.js|test.ts)$'],
testRegex: ['/test/.*\\.(test.js|test.ts)$'],
moduleFileExtensions: ['ts', 'js', 'json'],
snapshotResolver: '<rootDir>/scripts/snapshotResolver.js',
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
Loading