I am using rollup to build my TypeScript sources. I want to remove comments ONLY, without any minification, in order to hot update code when debugging.
I have tried rollup-plugin-terser
, it can remove comments but it will also minify my code somehow, I cannot completely disable the minification.
How can I do that? Thanks!
You should be able to achieve this too with just rollup-plugin-terser
. It bases on terser so more information it's actually available on its README, here is the part related to minification. So in your case this part of rollup.config.js
should looks like:
plugins: [
terser({
// remove all comments
format: {
comments: false
},
// prevent any compression
compress: false
}),
],
Keep in mind, that you can also enable part of configuration for production only. So having declared production
const in your rollup.config.js
you can do like that:
import { terser } from 'rollup-plugin-terser';
const production = !process.env.ROLLUP_WATCH;
export default {
plugins: [
production && terser({
// terser plugin config here
}),
],
};