Search code examples
javascriptwebstormuglifyjstraceur

Webstorm Uglify after Traceur compiler


I am using googles traceur (https://github.com/google/traceur-compiler) and have set up webstorm to watch traceur files and output them to a "public" directory.

Here is my traceur watcher arguments

--out public/$FilePathRelativeToProjectRoot$ --script $FilePathRelativeToProjectRoot$

This is working, however I want to run "uglify-js" on the outputted file from the traceur compiler.

My uglify arguments:

$ProjectFileDir$\public\$FileRelativePath$ -o $ProjectFileDir$\$FileRelativePath$

However instead of getting the one /public/ it runs with these arguments in the watcher

uglifyjs.cmd C:\Users\Dylan\WebstormProjects\circleUI\public\public\js\lib\easyA.js -o C:\Users\Dylan\WebstormProjects\circleUI\public\js\lib\easyA.js

Any Ideas?


Solution

  • If you need the watcher to listen to changes in certain file(s) only, you need to create a custom scope (Settings/Scopes) including these files only and set this scope to file watcher. And use

    $FileName$ -o <output path>

    as uglifier atguments

    With your settings, the non-existing files will be passed to uglifier in most cases. For example, let's imagine that the file foo.js located in $ProjectFileDir$/src folder has been modified. As a result, the following input will be passed to uglifier: $ProjectFileDir$/public/src/foo.js

    it's clear that the uglifier will fail then