Skip to content

Commit 35914c4

Browse files
committed
fix(tests): use path.resolve to generate outputFile path
update readme to reflect webpack's output.filename
1 parent a7468ad commit 35914c4

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ By using a function instead of a string, you can use chunk data to customize the
348348

349349
```javascript
350350
const miniCssExtractPlugin = new MiniCssExtractPlugin({
351-
filename: ({ name, chunkhash }) =>
352-
`${name.replace('/js/', '/css/')}.[chunkhash:8].css`
351+
filename: (chunkData) =>
352+
`${chunkData.name.replace('/js/', '/css/')}.[chunkhash:8].css`
353353
})
354354
```
355355

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class MiniCssExtractPlugin {
135135
this.options.chunkFilename = filename;
136136
} else {
137137
// Elsewise prefix '[id].' in front of the basename to make it changing
138-
this.options.chunkFilename = DEFAULT_FILENAME.replace(
138+
this.options.chunkFilename = filename.replace(
139139
/(^|\/)([^/]*(?:\?|$))/,
140140
'$1[id].$2'
141141
);

test/TestCases.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ describe('TestCases', () => {
8585
const expectedDirectory = path.resolve(directoryForCase, 'expected');
8686

8787
for (const file of walkSync(expectedDirectory)) {
88-
const actualFilePath = file.replace(
89-
new RegExp(`/cases/${directory}/expected/`),
90-
`/js/${directory}/`
91-
);
88+
const actualFilePath = path.resolve(outputDirectory, file);
9289
const expectedContent = fs.readFileSync(file, 'utf-8');
9390
const actualContent = fs.readFileSync(actualFilePath, 'utf-8');
9491

0 commit comments

Comments
 (0)