且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

开发工作流程 - Bootstrap(更少),Bower和Grunt

更新时间:2023-09-18 17:20:28

正如Bass Jobsen所述:

您不必复制bootstrap.less和variables.less。较少使用延迟加载和最后一次声明为变量获胜,因此可以在之后将它们的定义用于(重新)分配它们。创建一个project.less文件@import从你的bower文件夹中引导bootstrap.less,并在@import之后放置你的自定义变量赋值,混合和代码。


I am trying to step up my game as far as my folder structure and workflow is considered. I have recently discovered that front end package management and automation of tasks are key to improve speed, decreasing dev time, decrease file size and increase profit.

My issue is I am not too sure what the best method of using these tools are. I have a builds folder, which includes a dev and prod folder. My components are outside this folder in the bower_components folder.

I usually customise bootstrap and take advantage of it's variables file and mixins. I have copied the bootstrap.less file, and the variables.less file, and placed them in builds->dev->less. I then have grunt compiling the less using the bootstrap.less file from this new directory.

Is this the best way to go about using bootstrap and it's less files in this setup? I want to use bower due to it's power, but I also want to keep the power of customising bootstrap and it's less files.

What do you guys think?

NB: I usually code themes for brochure websites and very small applications.

As posted above by Bass Jobsen:

you don't have to copy bootstrap.less and variables.less. Less uses lazy loading and last declaration wins for variables, so to can put their definition afterwards to (re)assign them. Create a project.less file which @imports bootstrap.less from your bower folder and put your custom variables assignments, mixins, and code after the @import