But is it better handle the assignment by the parser instead of the lexer (as the most examples about the assignment that I see handle it in the parser)?
If whitespace generally serves to separate lexical tokens, then it is probably easier to avoid making an exception for variable assignments. Note that in the particular case of the shell command language, the specifications explicitly describe parsing in terms of lexical tokenization having been done that way, so in that case it is particularly appealing to write your code so that it corresponds directly to the specifications.
If you do that, then it is very helpful to also let the lexer recognize assignments as their own token type, as that information falls out of the lexical analysis pretty cheaply, whereas it would be messier and more expensive for the parser stage to (re-)check each token value to recognize which are assignments.
How to design the grammar to disable spaces around =?
If the whitespace rules are to be applied at the grammar level, as opposed to the tokenization level, then the tokenizer needs to emit explicit whitespace tokens so that the parser sees where the whitespace is. You can then write grammar rules that accommodate whitespace where it is allowed, and not where it isn't. But take it from someone who has done that (for a different language): it's ugly and nasty, and you should make every effort to avoid it.