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

查看:27
本文介绍了在 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天全站免登陆