Haji
Haji

Reputation: 1775

Combine r.js and UglifyJS parameters

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).

Upvotes: 0

Views: 866

Answers (2)

fractefactos
fractefactos

Reputation: 367

The only one way to use Uglify in command line is using:

optimize=uglify2

My reference is the source

Upvotes: 0

Haji
Haji

Reputation: 1775

According to James Burke who's responsible for r.js, this feature isn't supported yet - command line arguments are currently possible only for non-array attributes, see pull request 346.

Upvotes: 1

Related Questions