Skip to content

Commit

Permalink
Dependencies webpack plugin: Let the output file be specified when ou…
Browse files Browse the repository at this point in the history
…tput is combined (#20844)
  • Loading branch information
gziolo committed Mar 13, 2020
1 parent 34e7112 commit 565fce6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/dependency-extraction-webpack-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## Master

### New Features

- The plugin now supports an optional `combinedOutputFile` option that is useful only when another `combineAssets` option is enabled. It allows providing a custom output file for the generated single assets file ([#20844](https://github.com/WordPress/gutenberg/pull/20844)).

## 2.3.0 (2020-02-21)

### New Features

- The plugin now supports optional `combineAssets` options. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory ([#20330](https://github.com/WordPress/gutenberg/pull/20330)).
- The plugin now supports optional `combineAssets` option. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory ([#20330](https://github.com/WordPress/gutenberg/pull/20330)).

## 2.0.0 (2019-09-16)

Expand Down
7 changes: 7 additions & 0 deletions packages/dependency-extraction-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ The output format for the generated asset file. There are two options available:

By default, one asset file is created for each entry point. When this flag is set to `true`, all information about assets is combined into a single `assets.(json|php)` file generated in the output directory.

##### `combinedOutputFile`

- Type: string
- Default: `null`

This option is useful only when the `combineAssets` option is enabled. It allows providing a custom output file for the generated single assets file. It's possible to provide a path that is relative to the output directory.

##### `useDefaults`

- Type: boolean
Expand Down
5 changes: 4 additions & 1 deletion packages/dependency-extraction-webpack-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DependencyExtractionWebpackPlugin {
this.options = Object.assign(
{
combineAssets: false,
combinedOutputFile: null,
injectPolyfill: false,
outputFormat: 'php',
useDefaults: true,
Expand Down Expand Up @@ -106,6 +107,7 @@ class DependencyExtractionWebpackPlugin {
compiler.hooks.emit.tap( this.constructor.name, ( compilation ) => {
const {
combineAssets,
combinedOutputFile,
injectPolyfill,
outputFormat,
} = this.options;
Expand Down Expand Up @@ -180,7 +182,8 @@ class DependencyExtractionWebpackPlugin {
const outputFolder = compiler.options.output.path;
const assetsFilePath = path.resolve(
outputFolder,
'assets.' + ( outputFormat === 'php' ? 'php' : 'json' )
combinedOutputFile ||
'assets.' + ( outputFormat === 'php' ? 'php' : 'json' )
);
const assetsFilename = path.relative(
outputFolder,
Expand Down

0 comments on commit 565fce6

Please sign in to comment.