2016-06-14 49 views
0

我已經使用Angular CLI來構建我的第一個Angular2應用程序。我試圖利用Twitter的引導模塊,但它無法找到它:使用angular-cli時無法加載twitter引導資源

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:4200/node_modules/bootstrap/dist/css/bootstrap.css 

我有在

<link href="site.css" rel="stylesheet"> 

我下面的行一個index.html還那麼有在./public/site.css一行:

@import 'node_modules/bootstrap/dist/css/bootstrap.css'; 

引導程序模塊存在這裏./node_modules/bootstrap/dist/css/ ..但它仍然無法找到它。任何想法,我做錯了什麼?

回答

0

angular-cli-builds.js中,您需要添加該文件,以便在構建過程中將其複製。

vendorNpmFiles: [ 
    ... 
    'bootstrap/dist/css/bootstrap.css' 
] 

那麼這將是在供應商的文件夾瀏覽器中使用,所以更改site.css

@import 'vendor/bootstrap/dist/css/bootstrap.css'; 

如果它不工作,構建完成後,手動檢查dist/文件夾,找到該文件,並更新路徑...

更多的信息在這裏:​​

+0

輝煌 - 工作!謝謝你,我不會相信在我放棄和張貼之前,我有多少玩笑。謝謝。 –