在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";
- 混合应用程序中没有使用ion3上的keycloakauthentication
- 如何在Linux上使用Docker和Azure Web App部署Angular 4应用程序
- nginx.conf中的try_files不起作用
- 启动容器会导致错误
- docker工具中的angular色testing运行者不会在浏览器中打开
- 我如何使用Docker和Angular做实时更改重装?
- 为了开发目的,需要“app / dist”作为卷的一部分时,不能在容器中生成“app / dist”
- 如何在docker集装箱运行量angular器端到端testing?
- angular 5 nginx Docker expressconfiguration不加载mongoose数据