  Recent measurements of the electroweak-boson production performed by the
ALICE Collaboration are reported. The W-boson production was measured at
midrapidity in pp collisions at $\sqrt{s} = 13$ TeV, via the electronic decay
of the boson. It was also measured in association with a hadron emitted
back-to-back with respect to the electron. In heavy-ion collisions, the W- and
Z-boson production was measured at forward rapidity in p--Pb collisions at
$\sqrt{s_{\mathrm{NN}}} = 8.16$ TeV and Pb--Pb collisions at
$\sqrt{s_{\mathrm{NN}}} = 5.02$ TeV, in their muonic decay channel.
Measurements in pp collisions shed light on multiple parton interactions and
colour reconnection mechanisms. In heavy-ion collisions the measurements of
electroweak bosons allow to probe the initial state of the collision.
