Recently I wanted to import just .css file into .scss directly. This is not available directly in scss. However, you can import it when you change the extension from .css to .scss. While this solves generally problem then working with Bower components it becomes little bit painful when you’d need copy and change the name every time you install/upgrade the package.

In my particular case I wanted to include normalize.css in my scss files and I didn’t want to do manually copy&rename every time I install/upgrade normalize.css from Bower. So, in order to do the work automatically we can use Bower hook postinstall and run small batch script (I am referring to Windows) which will automate the work for us.

Here is what I did. In the Bower configuration file .bowerrc I’ve added:

"scripts": {
        "postinstall": "./.bower-postinstall.bat"
    }

and then .bower-postinstall.bat contains:

copy /y %CD%\vendor\bower\normalize-css\normalize.css %CD%\src\sass\common\normalize.scss

%CD% gives the current working directory. That’s all.

Comments

You can leave a response, or trackback from your own site.

Before you add comment see for rules.

Leave a Reply

Your email address will not be published. Required fields are marked *

0l4d0i