Search code examples
javascriptjquerygulpuglifyjs

Maintaining Certain Variables when using UglifyJS


I have a custom script that uses jQuery with the shorthand $("selector")notation. When I run my script through Uglify, the $ gets changed to a random letter, like a "e" or something, causing my jQuery functions in my script to break. How can I ensure that the $ doesn't get changed? I'm using Gulp for build, so is this something I need to set in my gulpfile?


Solution

  • Just for anyone that may see this in the future, I passed mangled: false as an option when using the uglify task in my gulpfile to solve this.