问题
After developing an alpha version of a Dart-based web application, I'm interested in testing the Dart2js deployment potentials of my app. However, it doesn't seem there is a "clean" way of creating a JS deployment version of the app - the dart2js code outputs stuff to the out directory, but there is other Dart stuff in there too. It seems things reference back to the web parent directory, and then there are all the packages references. I thought of copying all the stuff in out to a separate directory, but that doesn't seem to work.
Is there a clean way to create a deployment of the Javascript version of a Dart app?
Thanks in advance,
-D
回答1:
This is one of the joy's of living on the bleeding edge...
Check out this answer: what could be a deployment strategy with pubspec on dart
Another issue to track on the web ui project is:
- path fixing for resources (css, etc) breaks deployment
(Basically, you're waiting for the pub deploy
command to be created)
Update: Dartbug 6006 is being worked on at the moment, and says that it work like the following:
It'll copy everything in "web" into a deploy directory, run dart2dart and dart2js on all the entrypoints, and clean up the Dart source files. This will produce a directory that can be served without any additional steps.
回答2:
Just tried doing so.
The following steps should work:
- Create a Run Configuration. Be sure to use the html in the out directory as the target.
- Generate all necessary files (the JS, CSS, etc)
- Copy the all files in out directory to somewhere you want (your web site, for example).
- Change the supporting file locations in the html file. In particular, css, and the script src="packages/browser/dart.js"
Now you can directly run by double clicking the html file and/or launch it in the web server.
回答3:
Did you try: http://pub.dartlang.org/doc/pub-build.html
Use pub build when you’re ready to deploy your web app. When you run pub build, it generates the assets for the current package and all of its dependencies, putting them into a new directory named build.
来源:https://stackoverflow.com/questions/15143531/creating-a-javascript-deployment-set-from-dart2js-output