We derive an exact solution for the optical conductivity $\ensuremath{\sigma}(\ensuremath{\omega})$ of one hole in the Holstein $t\text{\ensuremath{-}}J$ model in the framework of dynamical mean-field theory. We investigate the magnetic and phonon features associated with polaron formation as a function of the exchange coupling $J$, electron-phonon interaction $\ensuremath{\lambda}$, and temperature. Our solution directly relates the features of the optical conductivity to excitations in the single-particle spectral function, revealing two distinct mechanisms of closing and filling of the optical pseudogap that take place upon varying the microscopic parameters. We show that the optical absorption at the polaron crossover is characterized by a coexistence of a magnon peak at low frequency and a broad polaronic band at higher frequency. An analytical expression for $\ensuremath{\sigma}(\ensuremath{\omega})$ valid in the polaronic regime is presented.