angular2种子项目中项目目录之外的文件 [英] Files outside of project directory in angular2 seed project

查看:58
本文介绍了angular2种子项目中项目目录之外的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何包含项目目录angular 2之外的文件?我有这样的文件夹结构WebApp(angular2种子)共享(业务逻辑文件)移动应用我在Web应用程序项目中的文件中给出了正确的文件路径,但是我被此错误所困扰http://localhost:5555/Shared/Services/RO/ROStep2Service.js 404(未找到)有人可以帮我告诉我如何添加项目目录之外的文件吗?

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

推荐答案

您可以通过添加自己的项目特定的gulp构建任务,并将其包括在构建管道中来实现.种子文档中有一节介绍如何配置这些任务: https://github.com/mgechev/angular-seed/tree/master/tools#tasks

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));
};

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

旁注:作为替代方案,如果您还没有走过Angular-Seed的道路,我建议您看一下使用Angular CLI构建项目作为更简单的替代方案(尤其是在升级版本时). https://angular.io/guide/quickstart

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

作为这种简单性的一个示例,要将新资产包含在Angular CLI项目中,只需修改 angular-cli.json 文件,以包含要包含的文件/文件夹的路径.简单,简洁.

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.

这篇关于angular2种子项目中项目目录之外的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆