官术网_书友最值得收藏!

  • Dart Cookbook
  • Ivo Balbaert
  • 399字
  • 2021-08-05 17:42:48

Publishing and deploying your app

There comes a point in time where you consider your app to be production ready, and you are eager to hand it over to your clients or users. If it is a web app in the Dart world at this moment in time, this means compiling to JavaScript. Luckily, the pub tool will take care of this stage in your app's life, so that your app can be deployed successfully.

Getting ready

This is pretty straightforward. To prepare, you need to run and test your application in both the checked and production modes.

How to do it...

Run the pub build command (see the Compiling your app to JavaScript recipe in Chapter 1, Working with Dart Tools), either from the command line or in Dart Editor. This creates the build folder with the subfolder bin or web, respectively, for a command-line or web application. The build folder contains complete deliverable files. The files generated in there can be deployed like any static content. Upload the JavaScript files together with the web pages and resources to any production web server.

How it works...

The pub build command is Dart's optimized command to create the deployment assets. It performs tree shaking so that only the code that is necessary during execution is retained, that is, functions, classes, and libraries that are not called are excluded from the produced .js file. The minification process further reduces the size of the file by replacing the names of variables, functions, and so on with shorter names and moving the code around to use a few lines.

There's more...

Some application hosting sites to run your app in the cloud are as follows:

Once your app is ready to be shared with other developers, it can also be published to the pub repository (verify the contents of your pubspec.yaml configuration file and the app's folder structure. For more detailed information, refer to https://www.dartlang.org/tools/pub/publishing.html.

主站蜘蛛池模板: 宣威市| 永宁县| 苗栗县| 杭锦后旗| 土默特左旗| 深州市| 勐海县| 安新县| 砚山县| 赣州市| 清原| 福泉市| 定远县| 昌图县| 伊宁市| 东源县| 嘉定区| 余江县| 石景山区| 迭部县| 新野县| 红桥区| 盘锦市| 宁国市| 繁昌县| 溧阳市| 龙游县| 封丘县| 保山市| 博白县| 清远市| 盐城市| 宕昌县| 寿光市| 武宁县| 余江县| 湟源县| 五莲县| 鄂伦春自治旗| 莱州市| 齐齐哈尔市|