从 Laravel 5.4 中删除 Glyphicons
Remove Glyphicons from Laravel 5.4
我有 laravel-5.4 项目,我想从中删除 Glyphicons。我从项目的根文件夹中尝试了以下命令:
npm uninstall glyphicons-halflings
那我运行npm run production
。然而,什么也没有发生,Glyphicons 字体保持原样。我怎样才能删除那个字体?
Glyphicons 包含在通过 npm 安装的 bootstrap-sass 中。
所以如果你想删除字形,你必须删除 bootstrap.js 文件中的 require('boostrap-sass')。
或者,如果您真的只想删除字体,那么您可以删除
node_modules/bootstrap-sass/assets/fonts/bootstrap
目录,但这可能会显示一个错误,即未找到字形图标。
要修复上述错误,您应该转到
node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss
文件并删除此代码
@import "bootstrap/glyphicons";
这个解决方案的问题可能是在你完成所有这些事情之后,你使用 npm 运行 update 更新你的依赖关系,然后你删除的所有东西都会更新到最新的 bootstrap -sass 依赖,除非你在 package.json
中删除了 bootstrap-sass 依赖
"devDependencies": {
"bootstrap-sass": "^3.3.7",
},
您可以将 bootstrap 定义复制到您的资源文件夹:
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 你需要添加这个文件来代替原来的 bootstrap import resources/assets/sass/app.scss
:
// Bootstrap
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "bootstrap";
在此之后 运行:
npm run dev
我有 laravel-5.4 项目,我想从中删除 Glyphicons。我从项目的根文件夹中尝试了以下命令:
npm uninstall glyphicons-halflings
那我运行npm run production
。然而,什么也没有发生,Glyphicons 字体保持原样。我怎样才能删除那个字体?
Glyphicons 包含在通过 npm 安装的 bootstrap-sass 中。 所以如果你想删除字形,你必须删除 bootstrap.js 文件中的 require('boostrap-sass')。
或者,如果您真的只想删除字体,那么您可以删除
node_modules/bootstrap-sass/assets/fonts/bootstrap
目录,但这可能会显示一个错误,即未找到字形图标。
要修复上述错误,您应该转到
node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss
文件并删除此代码
@import "bootstrap/glyphicons";
这个解决方案的问题可能是在你完成所有这些事情之后,你使用 npm 运行 update 更新你的依赖关系,然后你删除的所有东西都会更新到最新的 bootstrap -sass 依赖,除非你在 package.json
中删除了 bootstrap-sass 依赖"devDependencies": {
"bootstrap-sass": "^3.3.7",
},
您可以将 bootstrap 定义复制到您的资源文件夹:
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 你需要添加这个文件来代替原来的 bootstrap import resources/assets/sass/app.scss
:
// Bootstrap
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "bootstrap";
在此之后 运行:
npm run dev