2017-10-19 129 views
1

我有項目,我想從中刪除Glyphicons。我試過從我的項目的根文件夾下面的命令:從Laravel中刪除Glyphicons 5.4

npm uninstall glyphicons-halflings 

然後我運行npm run production。然而,沒有發生任何事情,Glyphicons字體保持原樣。我怎樣才能刪除該字體?

回答

2

Glyphicons包含在通過npm安裝的bootstrap-sass中。 所以如果你想刪除glyphicons,你必須在你的bootstrap.js文件中刪除require('boostrap-sass')。

或者,如果你真的想只刪除字體,然後刪除該

node_modules /自舉薩斯/資產/字體/引導

目錄,但是這可能會顯示一個錯誤,是glyphicons不位於。

要解決上述錯誤,你應該去

node_modules /自舉薩斯/資產/樣式表/ _bootstrap.scss

文件,並刪除該代碼

@import "bootstrap/glyphicons"; 

這個解決方案的問題可能是在你完成所有這些工作之後,你使用npm run update更新你的依賴關係,那麼你刪除的所有東西更新到最新的引導,青菜的依賴,除非你已經在你的package.json刪除引導,薩斯依賴

"devDependencies": { 
    "bootstrap-sass": "^3.3.7", 
    }, 
+0

非常好,所以,有沒有替代封裝引導,青菜使用字體真棒代替glyphicons,所以我安裝它? – SaidbakR

+1

抱歉,但我似乎無法找到像這樣的軟件包。 –

2

可以引導定義複製到你的資源文件夾:

mix.copy('node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss', 'resources/assets/sass/_bootstrap.scss'); 

和編輯這個文件通過刪除或註釋元素,你不想和更改所有路徑,實例字體:

resources/assets/sass/_bootstrap.scss

// Reset and dependencies 
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/normalize"; 
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/print"; 
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/glyphicons"; 

OFC你需要的地方原來的引導進口resources/assets/sass/app.scss的添加此文件:

// Bootstrap 
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; 
@import "bootstrap"; 

在此之後只需要運行:

npm run dev 
+0

這是更準確的答案,但是'resources/assets/sass/_bootstrap.scss'每次運行'npm run dev'都會被覆蓋 –