Ionic Serve taking too long


#1

Hello everyone,

when we run ionic serve it takes more or less 5 minutes to start the web browser.

Any idea how to optmize it? The problem is not only on my machine also on others’ machines.

That is our gulp:

var gulp = require("gulp"),
    gulpWatch = require("gulp-watch"),
    del = require("del"),
    runSequence = require("run-sequence"),
    argv = process.argv;


/**
 * Ionic hooks
 * Add ":before" or ":after" to any Ionic project command name to run the specified
 * tasks before or after the command.
 */
gulp.task("serve:before", ["watch"]);
gulp.task("emulate:before", ["build"]);
gulp.task("deploy:before", ["build"]);
gulp.task("build:before", ["build"]);

// we want to "watch" when livereloading
var shouldWatch = argv.indexOf("-l") > -1 || argv.indexOf("--livereload") > -1;
gulp.task("run:before", [shouldWatch ? "watch" : "build"]);

/**
 * Ionic Gulp tasks, for more information on each see
 * https://github.com/driftyco/ionic-gulp-tasks
 *
 * Using these will allow you to stay up to date if the default Ionic 2 build
 * changes, but you are of course welcome (and encouraged) to customize your
 * build however you see fit.
 */
var buildBrowserify = require("ionic-gulp-browserify-typescript");
var buildSass = require("ionic-gulp-sass-build");
var copyHTML = require("ionic-gulp-html-copy");
var copyFonts = require("ionic-gulp-fonts-copy");
var copyScripts = require("ionic-gulp-scripts-copy");

var isRelease = argv.indexOf("--release") > -1;

gulp.task("watch", ["clean"], function (done) {
    runSequence(
      ["sass", "html", "fonts", "scripts"],
      function () {
          gulpWatch("app/**/*.scss", function () { gulp.start("sass"); });
          gulpWatch("app/**/*.html", function () { gulp.start("html"); });
          buildBrowserify({ watch: true }).on("end", done);
      }
    );
});

gulp.task("build", ["clean"], function (done) {
    runSequence(
      ["sass", "html", "fonts", "scripts"],
      function () {
          buildBrowserify({
              minify: isRelease,
              browserifyOptions: {
                  debug: !isRelease
              },
              uglifyOptions: {
                  mangle: false
              }
          }).on("end", done);
      }
    );
});

gulp.task("fonts", function () {
    return copyFonts({
        src: [
            "node_modules/ionic-angular/fonts/**/*.+(ttf|woff|woff2)",
            "app/fonts/**/*.+(eot|ttf|woff|woff2|svg)"
        ]
    });
});

gulp.task("data", function () {
    gulp.src("S:\\data\\*.json")
        .pipe(gulp.dest("www/data"));
});

gulp.task("sass", buildSass);
gulp.task("html", copyHTML);
gulp.task("scripts", copyScripts);
gulp.task("clean", function () {
    return del("www/build");
});

And here also ionic.config.json:

{
  "name": "AnyName",
  "app_id": "",
  "v2": true,
  "typescript": true,
  "defaultBrowser": "chrome"
}

#2

What tends to slow down the whole build process is the addition/creation of sources maps. It does take some time to add these. We’re working on finalizing our build process to make it much faster.


#3

Is that is fixed on ionic 2 final resales?!