在angular-cli项目中更改目录结构 [英] Changing directory structure in an angular-cli project

查看:124
本文介绍了在angular-cli项目中更改目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在与angular-cli聊天,以决定是否要将其用作我们正在开始的新项目的基础.我们在Microsoft已有很长的历史,并且主要拥有服务器方面的知识,因此我们正在尽最大努力学习客户端框架领域的来龙去脉.我们喜欢angular-cli项目的内置测试,捆绑,摇树等功能,而保留这些功能正是我的问题.我们遇到了更改默认目录结构的需求.我们正在使用MVC来提供单个视图,该视图基本上将是angular应用程序的index.html文件.如果我们使用标准的angular-cli项目文件夹结构执行此操作,则该应用程序将无法运行或构建,因为所有路径引用都在寻找.\ src \ app ...

I have been noodling with angular-cli to decide if we want to use this as the basis for a new project we're starting. We're a long time Microsoft shop and have mostly server side knowledge so we're doing our best to learn the ins and outs of the client side framework world. We like the angular-cli project for it's built-in testing, bundling, tree shaking, etc and preserving these functions is what brings me to my question. We have come up against a need to change the default directory structure. We are using MVC to serve a single view that will basically be the index.html file of the angular application. If we do this with the standard angular-cli project folder structure, the app doesn't run or build because all path references are looking for .\src\app...

我需要知道的是,我需要在angular-cli设置中进行哪些更改,以便cli的自动监视,构建,绑定,测试等功能可以继续与此新结构一起使用,或者是这样吗?不是我们想要挖掘的东西,因为它将来会破裂吗?

What I need to know is what do I need to change in the angular-cli setup so that the automated watch, build, bindling, testing, etc features of the cli continue to work with this new structure, or, is this not something we want to dig into as it will just break in the future?

推荐答案

angular-cli中提供了许多自定义选项,您可以通过更新angular-cli.json文件来实现相同的目的.

There are lot of customization option available in angular-cli, you may do the same by updating angular-cli.json file.

    "root": "src",
    "outDir": "dist",
    "assets": [
        "assets"
      ],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "",
      "mobile": false,
      "styles": [

      ],
      "scripts": [

      ],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }

大多数配置是不言自明的,您可以使用它们来实现所需的功能.

most of the configurations are self explanatory, you may play with these to achieve what you need.

希望这会有所帮助!

这篇关于在angular-cli项目中更改目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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