I think I'm going insane, because every search engine throws me only results on how to remove the comments from output file and that's completely opposite of what I searched for
I use all defaults from Webpack 5, where Terser is built-in, so nothing in my webpack.config.js about this. My js
rules look like this:
{
test: /\.js/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
I have my main.js file that is minified as expected (required comments extracted to main.js.LICENSE.txt), but I also have a simple custom.js file which only has a comment and it should remain there in production:
/*!
* Keep this comment in production
*/
Few years back /*!
or //!
did the trick, but now nothing seems to work, even adding @license
or @preserve
to the comment like the docs suggest
If there's only comment, then production file is empty. If I add a console.log() to have required bit of code, then it does leave the comment, but only in another file custom.js.LICENSE.txt. What config do I need to keep this one file custom.js untouched with just this comment inside? I suppose I could use file-loader instead for this one, but I would like to have it compiled just like any other .js in case I need to add some code there. Just to always leave this one comment inside without extracting it to another file.