0

I've stucked with the problem in PhpStorm. I've added File Watcher for js files to minimize them (I'm using YUI Compressor JS). It works correct for js files and creates .min.js versions. But when I've created typescript file with the same name, YUI Compressor doesn't process js-file anymore.

For example if I have just one file script.js, YUI Compressor generates script.min.js successfully. But if I have 2 files script.ts and script.js and try to modify script.js, YUI Compressor doesn't generate script.min.js (no error output or any output at all, YUI Compressor doesn't fire).

Does anybody know what's wrong with it?

UPDATE:

LazyOne's solution (edit workspace.xml) works! But it seems oddly that I should use such workaround actions to do typical task. I never used typescript before, but a lot of peoples do. So, I think it should be typical task for them to minify js generated from typescript for production. Is there any other way for implementing task using standard built-in features in PHPStorm?

4
  • 1
    "I have 2 files script.ts and script.js..." This is because they both have the same name ... and script.js is most likely treated as a generated from/transpiled version of script.ts and therefore is ignored from indexing/parsing. See this answer: stackoverflow.com/a/61857426/783119 Commented Jun 8, 2020 at 12:17
  • You can also try forcibly manually running File Watcher on a file .. but it's inconvenient: stackoverflow.com/a/20012655/783119 Commented Jun 8, 2020 at 12:19
  • It works, thanks, LazyOne! But it seems oddly that I should use such workaround actions to do typical task. I never used typescript before, but a lot of peoples do. So, I think it should be typical task for them to minify js generated from typescript for production. Is there any other way for implementing task using standard built-in features in PHPStorm? Commented Jun 8, 2020 at 13:02
  • 1
    Use Webpack I guess (that will do compiling and the rest for your app)? Sorry, not using TypeScript myself so cannot give more precise answer on that. Commented Jun 8, 2020 at 13:15

1 Answer 1

2

The built-in TypeScript compiler, when enabled, auto-excludes the generated .js files from indexing for better performance and navigation by adding them to exactExcludedFiles list in workspace.xml. Related ticket: WEB-24568.

As a workaround, you need adding <option name="excludeGeneratedFiles" value="false" /> to your project workspace.xml:

  • Open .idea/workspace.xml
  • Replace <component name="TypeScriptGeneratedFilesManager"> section with the lines below:
 <component name="TypeScriptGeneratedFilesManager">
   <option name="version" value="1" />
   <option name="excludeGeneratedFiles" value="false" />
   <option name="exactExcludedFiles">
     <list>
     </list>
   </option>
 </component>
  • Re-open project
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.