Skip to content

Commit

Permalink
Merge pull request #121 from RunningCoderLee/master
Browse files Browse the repository at this point in the history
fix overwrite style file in preserveModules mode
  • Loading branch information
Anton Kudryavtsev authored Jun 11, 2020
2 parents 8d2c18e + 135b658 commit 1ab016b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ test("nested", async () => {
const inSource = `${outDir}/this/is/nested/${map.sources[0]}`;
await expect(fs.pathExists(inSource)).resolves.toBeTruthy();
const source = await fs.readFile(inSource, "utf8");
expect(map.sourcesContent && map.sourcesContent[0]).toBe(source);
expect(map.sourcesContent?.[0]).toBe(source);
});

test("augment-chunk-hash", async () => {
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ export default (options: Options = {}): Plugin => {

const getName = (chunk: OutputChunk): string => {
if (opts.file) return path.basename(opts.file, path.extname(opts.file));
if (preserveModules) return path.basename(chunk.fileName, path.extname(chunk.fileName));
if (preserveModules) {
const { dir, name } = path.parse(chunk.fileName);
return dir ? `${dir}/${name}` : name;
}
return chunk.name;
};

Expand Down

0 comments on commit 1ab016b

Please sign in to comment.