在Docker中使用自动构build不能使用Bootstrap样式?

我正在学习使用Docker在本地开发复杂的应用程序,并决定使用angular2作为起点。

我已经使用angular-cli并从以下位置获取图片: https : //hub.docker.com/r/trion/ng-cli/

这工作非常好,我正在取得进展。 然而,更新我的代码库来testingBootstrap是否导入,我没有看到任何样式。 如果有人能够build议我们如何克服这一点,我会永远感激:

码:

(模块)

import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { AlertModule } from 'ngx-bootstrap'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, AlertModule.forRoot() ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } 

从angular-cli.json中创build样式数组

 "styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "styles.css" ], 

来自模板的代码:

 <h1> {{title}} </h1> <table class="table table-striped"> <tr> <th>ID</th> <th>Film Title</th> </tr> <tr *ngFor="let film of films"> <td>{{ film.id }}</td> <td>{{ film.name }}</td> </tr> </table> <alert type="success">hello</alert> 

试了几个哈克的方法,但没有任何工作。 这是否与没有Dockerfile有关? 刚刚学习Docker,所以任何帮助表示赞赏。

这可能不是Angular也不是Docker相关的,但更多的是项目configuration的问题。

为了使样式得到导入,您有两个select:

您可以通过.angular-cli.json中的“styles”属性添加到项目中。 为此,你需要知道所有的文件定义都是相对于src文件夹的,所以你的定义将不起作用,你必须使用类似这样的东西:

  "styles": [ "../node_modules/bootstrap/dist/css/bootstrap.css", "styles.css" ], 

或者你可以通过styles.css文件中的css import导入它们,如下所示:

 @import "~bootstrap/dist/css/bootstrap.css";