Reputation: 86790
My Angular2 project having 100+ Css files, those files does't have any prefixer like for :Mozila, :Chrome etc, i want some tool or any gulp task or anything which will convert my all css files into files having prefixers.
I have tried this
but not working as per my use case,
so is it possible ? if yes how ?
Upvotes: 0
Views: 496
Reputation:
Since you asked for an answer :
In your IDE (I take Visual Studio Code as an example):
.*
)Enter your regex. It goes like this
^\s*([a-z-]*)\s*:\s*([\d\w-()"\s\.:=!@]*);?\s*$
In the second field, use something like
moz-$1: $2;\nsafari-$1: $2;
It will add "moz-" to every property found by the regex.
Of course I typed it fast, so you will have to make some adjustements, but the idea is here.
EDIT AFTER CHAT Here is the explanation :
To answer how it's possible : when you put parenthesis in a regex, it "captures" what it finds and register it in a variable starting with a $ sign. That's why you write $1, $2 in the replace string, because it captured the property name, and the property value. The \n allows a line return, and all you have to do is put as many prefixes as you want like that !
Upvotes: 1
Reputation: 1073
There is a node.js tool called Autoprefixer, which does exactly what you need. PostCSS autoprefixer is actually only a wrapper around it. You can use it directly.
If you don't use Gulp, Grunt or some other task runner, you can use Autoprefixer manually from command line.
First install it:
npm install -g autoprefixer
Then use it on some file:
autoprefixer file.css
Or on multiple files:
autoprefixer -d processed *.css
Upvotes: 1