I’m learning Dart and its dependency manager
pub and am having a tough time seeing the “forest through the trees” here.
Say I want to use Polymer.dart in my project. So, in my project root, I create the following
name: test_dart description: A sample web application dependencies: browser: any polymer: ">=0.9.0 <0.10.0"
I then run
pub get, which goes to the
pub repo and fetches the
polymer dependencies that I’ve specified. It then creates a
packages directory in my project root, which now means I have a project that looks like:
MyDartProject/ pubspec.yaml myapp.dart packages/ browser/ ... ...all the packages that ship with Polymer
Now I start coding my Dart web app (
myapp.dart), which will references various Polymer and
browser types/functions/etc. in its source code.
According to the
dart2js docs, I need to run something like:
dart2js --out=myapp.js --package-root=??? myapp.dart
How do I include all the browser & polymer packages on the buildpath?
There is a “pub build” option now.
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.
$ cd ~/dart/helloworld $ pub build Building helloworld...... Built 5 files!
If the build directory already exists, pub build deletes it and then creates it again.
That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose “pub build”
EDIT: You should also see the links in zoechi’s answer.
Answered By – Paul Collingwood
Answer Checked By – Marie Seifert (FlutterFixes Admin)