Page 38 - Dart Language
P. 38

Chapter 15: Pub




        Remarks



        When you install the Dart SDK, one of the tools that you get is pub. The pub tool provides
        commands for a variety of purposes. One command installs packages, another starts up an HTTP
        server for testing, another prepares your app for deployment, and another publishes your package
        to pub.dartlang.org. You can access the pub commands either through an IDE, such as
        WebStorm, or at the command line.

        For an overview of these commands, see Pub Commands.



        Examples


        pub build


        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 new directory
        named build.


        To use pub build, just run it in your package’s root directory. For example:


         $ cd ~/dart/helloworld
         $ pub build
         Building helloworld......
         Built 5 files!


        pub serve


        This command starts up a development server, or dev server, for your Dart web app. The dev
        server is an HTTP server on localhost that serves up your web app’s assets.


        Start the dev server from the directory that contains your web app’s pubspec.yaml file:


         $ cd ~/dart/helloworld
         $ pub serve
         Serving helloworld on http://localhost:8080


        Read Pub online: https://riptutorial.com/dart/topic/3335/pub

















        https://riptutorial.com/                                                                               33
   33   34   35   36   37   38   39   40   41   42