abhilash reddy
abhilash reddy

Reputation: 1586

Files outside of project directory in angular2 seed project

How do i include file which is outside of project directory angular 2? I have the folder Structure something like this WebApp(angular2 seed) Shared(business logic files) Mobile App I gave the correct file path in a file in my web app project but i am stuck with this error http://localhost:5555/Shared/Services/RO/ROStep2Service.js 404 (Not Found) Can Somebody please help tell me how can i include the file which is outside of my project directory

Upvotes: 2

Views: 617

Answers (1)

Steve Land
Steve Land

Reputation: 4862

You can do this by adding your own project specific gulp build tasks, and including these in your build pipeline. The seed documentation has a section on how to configure these tasks: https://github.com/mgechev/angular-seed/tree/master/tools#tasks

You can base your task on the existing seed task which copies all prod assets to your build destination folder:

export = () => {
  let es: any = require('event-stream');
  return gulp.src([
    join(Config.APP_SRC, '**'),
    join(Config.NPM_BASE, '@angular', 'service-worker', 'bundles', 'worker-basic.min.js'),
    '!' + join(Config.APP_SRC, 'tsconfig.json'),
    '!' + join(Config.APP_SRC, '**', '*.ts'),
    '!' + join(Config.APP_SRC, '**', '*.css'),
    '!' + join(Config.APP_SRC, '**', '*.html'),
    '!' + join(Config.APP_SRC, '**', '*.scss'),
    '!' + join(Config.APP_SRC, '**', '*.sass'),
    '!' + join(Config.ASSETS_SRC, '**', '*.js')
  ].concat(Config.TEMP_FILES.map((p) => { return '!' + p; })))
   .pipe(onlyDirs(es))
   .pipe(gulp.dest(Config.APP_DEST));
};

From: https://github.com/mgechev/angular-seed/blob/master/tools/tasks/seed/build.assets.prod.ts

Side note: As an alternative, if you havent travelled too far down the Angular-Seed path, I would recommend you have a look at building your project using the Angular CLI as a much simpler alternative (especially when upgrading versions). https://angular.io/guide/quickstart

As an example of this simplicity, to include new assets with an Angular CLI project, you just modify your angular-cli.json file, to include the path to the file/folder you want included. Simple, and concise.

Upvotes: 1

Related Questions