The contribution of components like dark matter, stars and gas to the mass of a galaxy
This is a rather complex question, for several reasons.

First, galaxies come in many variations, regarding such diverse
properties as mass, morphology, and environment.
Second, different observational techniques, and different models,
yield different observables — you can observe the same field of the
sky with two different instruments and deduce a different
distribution of galaxies and their properties.
Third, as you mention, galaxies evolve, and you will not necessarily
obtain the same ratio between, say, gas mass and stellar mass, even for a
given galaxy type, at different redshifts.

Nevertheless, some things can be said to be true &quot;in general&quot;:
Stellar mass – gas mass relation
The more massive a galaxy is (in terms of stellar mass, $M_*$), the more efficient it is at forming stars. Hence, the gas fraction $f_\mathrm{gas} \equiv M_\mathrm{gas}/(M_\mathrm{gas}+M_*)$ decreases with $M_*$. Moreover, although part of the gas in stars is returned to the interstellar medium (ISM), as time goes, and a galaxy forms stars, it will &quot;deplete&quot; the ISM, further reducing $f_\mathrm{gas}$.
This can be seen in this plot from Magdis et al. (2012), showing the gas fraction as a function of stellar mass today (open circles) and ~10 billion years ago (closed circles):

The galaxies used in this survey are &quot;main sequence&quot; galaxies, and other selection criteria apply as well.
Stellar mass – halo mass relation
The dark matter (DM) component of a galaxy is much more extended and diffuse than the baryons (because DM is collisionless), rather lying in a large &quot;halo&quot; around the gas and stars. Of course, we cannot see DM, making measurements of its mass difficult. Only in numerical simulations, we know exactly its mass.
The larger the DM halo mass ($M_\mathrm{h}$), the more stars the galaxy has. But the relation is not straightforward. In general, $M_*$ increases with $M_\mathrm{h}$ more rapidly for low-mass galaxies, while for $M_\mathrm{h} \gtrsim 10^{12}\,M_\odot$ (roughly Milky Way-sized galaxies) the relation flattens out:
This is seen in the left panel of this plot from Behroozi et al. (2013):

The different colors correspond to different epochs in the Universe. The data is from a cosmological simulation, but the simulation was calibrated to match various observations.
Another way to show this relation is seen in the right panel, where the stellar fraction $M_*/M_\mathrm{h}$ is seen to rise until around $M_\mathrm{h} \sim 10^{12}\,M_\odot$, after which it decreases again.
Why is this? In general it is thought that star formation is suppressed at low masses because gas is more easily expelled from a shallow gravitational potential, while a high masses, active galactic nuclei become very efficient at blowing out gas, thus quenching star formation.
How are masses measured?
There are several techniques to measuring these masses.
Stellar masses are measured using known relations between the amount of stars and the amount of light from some physical process — either a single emission line, or a broader band of light. For highly star-forming galaxies, where there are still many hot O and B stars that ionize the surrounding gas, nebular lines such as H$\alpha$ or Ly$\alpha$ can be used, while for non-star-forming galaxies you can use e.g. the continuum radiation from heated dust.
The conversion depends on the assumed initial mass function of the stellar population.
Likewise, gas masses and molecular masses may be measured knowing how much light a given amount of gas emits (at a given temperature, pressure, …).
Measurements of halo masses are typically done looking at the width of various spectral lines, thus deducing the velocity dispersion $\sigma_V$ of the gas and stars. Then, the total mass $M$ can be calculated from
$$
\sigma^2 = \frac{GM}{CR},
$$
where $G$ is the gravitational constant, $R$ is the radius, and $C$ is a geometrical factor (see this answer for an explanation).