I'm optimizing my requirejs project with r.js. In my JS code, I need to replace an alias with the version number. It works fine when my build.js
file contains the following:
({
appDir: "../",
baseUrl: "scripts",
mainConfigFile: 'project-config.js',
dir: "../dist",
uglify: {
defines: {
DEBUG: ['name', 'true'],
VERSION: ['string', '1.2.3.4']
}
}
})
I run it via:
node r.js -o build.js
However, I need the version number to be passed dynamically as I want to optimize it through some command line tool. I've read about the --define SYMBOL[=VALUE]
option in the UglifyJS documentation, but couldn't make it to work together.
What should I change in the node command to pass a "define" parameter to UglifyJS? I want to override the VERSION definition from the build.js file (or simply remove it from the file).