František Šitner
František Šitner

Reputation: 51

How to transpiling dart to javascript in Phpstorm

I installed dart-sdk and downloaded dart plugin to Phpstorm 8.0.3, but I cant figure out how to transpile dart to js. When I am trying to make file watcher I dont have any Dart2Js predefined template in settings.

Thank you

Upvotes: 1

Views: 447

Answers (2)

lena
lena

Reputation: 93748

See @Günter Zöchbauer answer. Using dart2js is not the recommended approach, as it runs on file level instead of project, creates output in the src folder, etc. - but the main reason is that it is not clear when/why to use it. If you need to build your project, use 'pub build' (available in pubspec.yaml right-click menu). When debugging in browser, 'pub serve' is always used implicitly - it performs all needed transformations... But, if you still need this watcher, you can easily configure it yourself by adding a watcher of 'custom' type.

Program: path/to/dart2js
Arguments: --out=$FilePath$.js $FilePath$
Working directory: $FileDir$
Output paths: $FileName$.js:$FileName$.js.map:$FileName$.js.deps

Upvotes: 2

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657416

I know only WebStorm 9 and 10. Maybe you can still derive how it might work in PHPStorm.

Usually you don't want to build to JavaScript on each file change because this would slow your machine down.
During development you use pub serve which is automatically launched by WS 9 and 10 and which transpiles Dart files to JavaScript only on demand (when requested by a browser) and only compiles what it didn't compile previously.

For deployment WebStorm can use the Pub: build ... context menu of the pubspec.yaml file in the project view.

Upvotes: 3

Related Questions