Customize bootstrap outside vendor folder

[size=2]I’ve got a working Yii2 site, based on the Basic template, installed by composer. [/size]

Now I want to override and extend the styles provided by bootstrap.

Normally I would make my own less-file, and add it to the gruntfile inside vendor/.../bootstrap. Then I can re-use boostrap mix-ins and use grunt to build my css.

But to safely be able to update yii, bootstrap, extensions etc. I want to stay away from the files inside vendor folder. The fact that the default .gitignore file exclude vendor tells me I might be wise to stay true to that.

If I just add a custom css to the assetBundle the custom css will be added before bootstrap, thus not overriding its properties.

So, what is the best practice for structuring custom less/css files?

Ok, so here is what I ended up doing:

I created a new grunt-project under the assets folder, with the necessary plugins to compile .less. Still not sure that is the best place, but it works, and make sense in some ways.

In Gruntfile.js I added the folder where bootstraps .less-files resides (vendor/bower/bootstrap/less) to the paths.

Then I created my own AssetBundle-class, and added it to $depends-array in assets/AppAsset.php. In my own AssetBundle-class I am free to specify my own css-files to be included.

I am now able to override bootstrap, import mixins and manage my own additions in git, while keeping vendor-folder clean and updated.