How to prevent parcel from strippings comments from specific lines in source file?
I am creating a website which contains a code editor. The code editor will have some code in it by default. I would rather not encode the code into a string (in order to pass it into the editor.session.setValue() function) using an online encoder. Instead, I would like to just write the code and use the .toString() in order to get a string representation of the code. However, parcel build will strip out the comments, which is problematic, because I need the comments.
Ideal Code:
let afunc = () => {
//Print hello world - this comment will not be removed
console.log("hello world")
}
editor.session.setValue(afunc.toString())
What actually happens in the above example is that the comment is removed.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel |
| Node |
| npm/Yarn |
| Operating System |
Parcel supports customizing terser options, see possible options here https://github.com/fabiosantoscode/terser#output-options
An example to not remove comments:
.terserrc
{
"output": {
"comments": "put some regex here"
}
}
Most helpful comment
Parcel supports customizing terser options, see possible options here https://github.com/fabiosantoscode/terser#output-options
An example to not remove comments:
.terserrc