Skip to content

Commit ba5c16f

Browse files
authored
Merge pull request #3 from AnujRNair/an/issue-2-try-catch-map-file-removal
ISSUE-2: Wrap .map removal in try catch incase they dont exist
2 parents a659d85 + d8eac1d commit ba5c16f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A webpack plugin to remove unwanted files which may have been created and output
44

55
## Problem
66

7-
When using ExtractTextPlugin, it's not possible to generate a css file for each chunk webpack outputs, if you're using [code splitting]([https://webpack.js.org/guides/code-splitting/]).
7+
When using ExtractTextPlugin, it's not possible to generate a css file for each chunk webpack outputs, if you're using [code splitting](https://webpack.js.org/guides/code-splitting/).
88

99
The only possible way to do this is to have an entry point for each top level css / less / scss file, however this will create small js files with empty webpack functions in them, which are undesirable.
1010

Diff for: lib/plugin.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ ExtraneousFileCleanupPlugin.prototype.apply = function (compiler) {
7171

7272
// remove from various places
7373
fs.unlinkSync(outputPath + '/' + assetKey) // unlink the asset
74-
fs.unlinkSync(outputPath + '/' + assetKey + '.map') // unlink the map file
7574
delete compilation.assets[assetKey] // remove from webpack output
76-
delete compilation.assets[assetKey + '.map'] // remove from webpack output
75+
76+
// remove map file from various places if it exists
77+
try {
78+
fs.unlinkSync(outputPath + '/' + assetKey + '.map') // unlink the map file
79+
delete compilation.assets[assetKey + '.map'] // remove from webpack output
80+
} catch (e) {}
7781

7882
if (usingManifestJson) {
7983
for (manifestKey in manifestJson) {

0 commit comments

Comments
 (0)