Skip to content

Commit aac26b3

Browse files
committed
feat(server): add outputPath option in ChunkExtractor
1 parent 18a719d commit aac26b3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/server/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ Used to collect chunks server-side and get them as script tags or script element
193193
| `options.statsFile` | Stats file path generated using `@loadable/webpack-plugin`. |
194194
| `options.stats` | Stats generated using `@loadable/webpack-plugin`. |
195195
| `options.entrypoints` | Webpack entrypoints to load (default to `["main"]`). |
196+
| `options.outputPath` | Optional output path (only for `requireEntrypoint`). |
196197

197198
You must specify either `statsFile` or `stats` to be able to use `ChunkExtractor`.
198199

packages/server/src/ChunkExtractor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ function joinTags(tags) {
7777
}
7878

7979
class ChunkExtractor {
80-
constructor({ statsFile, stats, entrypoints = ['main'] } = []) {
80+
constructor({ statsFile, stats, entrypoints = ['main'], outputPath } = []) {
8181
this.stats = stats || smartRequire(statsFile)
82+
this.outputPath = outputPath || this.stats.outputPath
8283
this.statsFile = statsFile
8384
this.entrypoints = Array.isArray(entrypoints) ? entrypoints : [entrypoints]
8485
this.chunks = []
@@ -101,7 +102,7 @@ class ChunkExtractor {
101102
scriptType: extensionToScriptType(path.extname(filename).toLowerCase()),
102103
chunk,
103104
url: this.resolvePublicUrl(filename),
104-
path: path.join(this.stats.outputPath, filename),
105+
path: path.join(this.outputPath, filename),
105106
type,
106107
linkType,
107108
}

0 commit comments

Comments
 (0)