Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/webpack/delete-unused-entries-js-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DeleteUnusedEntriesJSPlugin.prototype.apply = function(compiler) {

// loop over the output files and find the 1 that ends in .js
chunk.files.forEach((filename) => {
if (/\.js(\?[^.]*)?$/.test(filename)) {
if (/\.js(\.map)?(\?[^.]*)?$/.test(filename)) {
fileDeleteCount++;
// remove the output file
delete compilation.assets[filename];
Expand All @@ -32,10 +32,10 @@ DeleteUnusedEntriesJSPlugin.prototype.apply = function(compiler) {
}
});

// sanity check: make sure 1 file was deleted
// if there's some edge case where multiple .js files
// sanity check: make sure 1 or 2 files were deleted
// if there's some edge case where more .js files
// or 0 .js files might be deleted, I'd rather error
if (fileDeleteCount !== 1) {
if (fileDeleteCount === 0 || fileDeleteCount > 2) {
throw new Error(`Problem deleting JS entry for ${chunk.name}: ${fileDeleteCount} files were deleted`);
}
}
Expand Down
31 changes: 31 additions & 0 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,37 @@ describe('Functional tests using webpack', function() {
done();
});
});

it('With source maps in production mode', (done) => {
const config = createWebpackConfig('web', 'production');
config.addEntry('main', './js/no_require');
config.setPublicPath('/');
config.addStyleEntry('styles', './css/h1_style.css');
config.enableSourceMaps(true);

testSetup.runWebpack(config, (webpackAssert) => {
expect(config.outputPath).to.be.a.directory()
.with.files([
'main.js',
'main.js.map',
'styles.css',
'styles.css.map',
'manifest.json'
// no styles.js
// no styles.js.map
]);

webpackAssert.assertManifestPathDoesNotExist(
'styles.js'
);

webpackAssert.assertManifestPathDoesNotExist(
'styles.js.map'
);

done();
});
});
});

it('enableVersioning applies to js, css & manifest', (done) => {
Expand Down