Closed nikolay-borzov closed 4 years ago
I can't seem to reproduce this. I've modified the simple
example to basically match the configuration you provided:
const path = require('path');
const SVGSpritemapPlugin = require('../../lib');
module.exports = {
mode: 'development',
output: {
path: path.join(process.cwd(), '/shop-static/assets/'),
hashDigestLength: 8,
filename: './js/[name].js',
chunkFilename: './js/[name].js'
},
plugins: [
new SVGSpritemapPlugin('src/**/*.svg', {
output: {
filename: 'spritemap',
svgo: {
plugins: [{ removeTitle: true }]
}
}
})
]
};
And it's not generating a file for the chunk on my end, just a js/main.js
and spritemap
file. Do you have some more information/could you debug it a bit more yourself?
Couple of notes:
.svg
in the output.filename
plugin option so it's generating a file without an extension this way.path: '/shop-static/assets/'
generates a file on the root level of your file system, I had to use path.join(process.cwd(), '/shop-static/assets/')
to even get it to compileI'll try to create a reproducible example in a separate repo. Maybe it's somehow caused by splitting entry point in chunks
Here https://github.com/nikolay-borzov/svg-spritemap-webpack-plugin-117. Looks like setting
optimization: {
splitChunks: {
minSize: Infinity,
maxSize: Infinity
}
}
causes the issue
Interesting, any reason you're setting both the minSize
and maxSize
to Infinity
? That doesn't make any sense to me on a logical level, e.g. why would you want to split chunks only when their size is infinite? 🤯
It's complicated) Setting Infinity
size prevents webpack from spilling chunks into multiple files because of the size. This way we can get the same files number as in the production build. This allows mapping development chunks to production chunks while debugging the production site.
I'll take a look at what happens when using those settings but I don't understand why you wouldn't use mode: 'production'
together with sourcemaps in that scenario 🤯
why you wouldn't use
mode: 'production'
together with sourcemaps in that scenario 🤯
"Security" (Customer requirement)
By the way, the issue reproducible even when minSize
and maxSize
have sensible values like 1024
and 2048
Alright, looks like the splitting of chunks does indeed cause issues with cleaning up, I've added some extra logic 3a9bdb3 that should handle this. Could you test if this solves the issue on your end as well? You can install the version directly from that branch by running
npm install --no-save cascornelissen/svg-spritemap-webpack-plugin#117
"Security" (Customer requirement)
As long as you're not deploying the sourcemaps to your actual production environment I don't see how that's any different to building the application without minification etc. but if it works it works right 🤷🏼♂️
I confirm dummy-module is no longer remains after the build on my project.
@nikolay-borzov, the fix for this issue has been released in version 3.5.8
🚀 Thanks for reporting the bug and helping me debug it!
Thank you for the quick fix!
@cascornelissen, is it possible to exclude the dummy module from stats.compilation.chunks
?
I'm not sure but I don't think it is. The dummy module needs to be created and we can't get rid of it until the files are emitted and I'm pretty sure the stats are combined before that point...
But if you want to try it out, you can give it a go I guess.
I see. Thanks.
webpack
:4.44.1
svg-spritemap-webpack-plugin
:3.5.7
Config like:
When I added
console.log
here:I saw: