There was this interchange with Korob in the episode "Catspaw:"
MCCOY: These look real [regarding the plate full of gemstones].
KOROB: They are, I assure you. Diamonds, rubies, emeralds, sapphires. All the crystalline forms that you cherish above all things. A fortune of them for each of you--if you leave here without further inquiry.
KIRK: We could manufacture a ton of these on our ship. They mean nothing to us.
So, while they are capable of manufacturing diamonds, rubies, emeralds, sapphires--all the crystalline forms that are cherished above all things, evidently (and perplexingly) dilithium is something that can't be manufactured shipboard.