Use the Caching Shader Preprocessor.
The Caching Shader Preprocessor is a shader preprocessor that is optimized for fast compilation. It caches intermediate preprocessing data to speed up shader import and compilation in the Unity Editor. It offers improved performance over platform compilers' preprocessors and has well-defined behaviour across all platforms and shader types.