In Star Trek, it seems like they take forever to build ships. It takes months, if not years to make them. So why not just build gigantic replicators in space, then replicate the ship (excepting non-replicatable objects like the warp core)? This would presumably come with a huge energy cost, but would save massive amounts of time.
With regards whole ship replication, there are notes in the Next Generation Technical Manual. It states that replication of an entire ship would take too many resources/too much energy. The behind-screen notes say this is for dramatic effect as the viewer would care too little for the fate of the ship if they can just replicate a new one in minutes.
From Construction Chronology (P17):
Given the existence of matter replication devices (like the show's "food replicator" terminals), a very logical question is: "Why can't they just replicate entire starships?" The real reason is that such an ability would allow us to create entire fleets of starships at the touch of a button. This might be great for Federation defense and science programs, but makes for poor drama. For this reason, starship construction facilities (seen at Utopia Planitia in "Booby Trap" and Earth Station McKinley "Family") have been depicted as construction platforms rather than large replicators. We assume that replication is practical for relatively small items, but that energy costs would be prohibitive for routine replication of larger objects. (Jon Singer points out that if you could make a starship at the push of a button, you wouldn't need to....)
I would think that the cost/resources needed to make a replicator that size would take so long that it wouldn't be feasible.
I would think that it would be more cost effective to have small replicators to replicate all the parts, then have people or machines build the ships.
This would also give people jobs which would help with the whole 'perfect utopia' of Earth that Star Trek was trying to create.
I think that they do, at least they replicate the majority of the components and assemble them by hand.
Star Trek: Enterprise foreshadowed the eventual use of replicators in the Dead Stop, where an automated repair station not only have the ability of replicating food but also ship components on-the-fly.
It stands to reason that replicators are how crews are able to repair massive damage to their vessels without the need to drydock.
Smaller replicators make much more sense than larger, ship-producing ones given their versatility: you can make components, useful for both construction and repair.
Plus there could also be a relation to the amount of energy and resources needed according to the size of the replicator. In other universes, for example Stargate SG-1, the power requirements for the Stargate go up exponentially the larger the ring gets. The same could be true in Star Trek: the larger the replicator, the greater the power draw to the point of being beyond diminishing returns.
There are industrial replicators, ostensibly used for mass production of components, but not anything as large as a starship. Replication requires a lot of energy (as evidenced by the rationing of their use on the USS Voyager) and it is very likely that assembly of components is more feasible than replicating a finished product.
For the same reason that they still farm and mine minerals. Storage is at a premium on a starship, so there is nowhere near enough room to store months and months of food for hundreds or thousands of people.
Therefore, there is an advantage to replicate food so you don't have to carry it, even though a single apple might require many times as much energy to "build" out of subatomic particles as it takes to grow. The benefits outweigh the costs for space travel, but if it takes a billion units of energy to construct a starship out of mined materials, it might take a quintillion units of energy to entirely replicate one.
Similarly, they can replicate critical parts onboard rather than having thousands of parts prebuilt, stored onboard, and waiting, or finding, retrieving, processing, and fabricating the parts.
So the advantage is that a unit the size of a refrigerator takes the place of a dozen farms, a kitchen, a mine, a foundry, a factory, a tailor, and countless other facilities, with the expense of consuming a huge amount of energy. The fact of the matter is that without one, the ships would need to come back to port every month, or be met wherever they were by a resupply ship, periodically, which would badly impair their ability to explore.
The replicators work very similarly to how the transporter works. It is to put it simply a matter energy converter. It takes energy from the ship which is fueled by deuterium then converts it into matter. The size of the replicators adds to the power draw along side the energy required to be converted into matter.this means that large replicators would not be as efficient as several smaller ones. On top of this the replication of smaller parts allows for more room for error because if there is a defect instead of Dematierializing a large object and thus using more energy, they can dematierialize a small object and expend less.on top of all this if it is put together by people or machines it gives error control meaning that instead of the whole ship being faulty. Its just one piece which a builder can spot, identify and get rid of.
There is also the fact that SF is not a military organization intent on conquest so mass production is not a Necessity instead focus is put on innovation and improvements for each new ship which is something that requires finesse and precision changes not to mention R&D etc. this is why you never see two ships that look 100% the same!
I can imagine there is no in-universe reasons preventing SF from replicating ships. Indeed, they might actually do this. They replicate ships in sections and then automation would assemble them. I never saw the point in Humanoids doing the manual work of building ships. That's too time consuming and prone to errors. Automating ship construction would be thousands of times faster... and for a technologically advanced civilization, this WOULD be the way to do things in space.
Look at the amount of things that can be automated in real life. SF has so much more advanced computers than we do which can easily be delegated to ship building and eliminate the manual labour from the process. Same can be said for repair capabilities. Self-repair would be more than possible... and it was implied in early TNG with the ship cleaning and maintaining itself.
At any rate... replicators... they were described in both Voyager and TNG as technology that converts energy into matter. So, actual raw matter is not needed for replicators to function - only energy. This is consistent with replicators being relatively high in terms of power consumption and why in one of the episodes of TNG it was stated that the ship doesn't have the energy to create complex elements.
Theoretically, replicators don't have limitations on what they can create. The energy amount is what matters. So, the more complex a material is, the greater the energy demands will get.
SF ships are primarily powered by matter-antimatter reactions and this provides HUGE amounts of energy. Technical efficiency allows us to do more with less, so realistically, as SF improves their replication capabilities, the energy demands on replicating complex materials goes down, and their power generation also greatly improves (power output) by lowering the size requirements.
One aspect of how ship construction in the 24th century could be done is by using solar energy for the purpose of power generation. To further elaborate: there's enough power hitting the Earth in just 1 hour which would be enough to power the globe for a full year. The globe is at the moment using about 0.5 Zettajoules of power per year (considering that 1 third of Humanity doesn't have access to electricity, let's increase those power demands to about 0.8 Zettajoules per year for the ENTIRE globe).
The next bit is only for comparison purposes: "The MIT Report in 2006 calculated the world's total EGS resources to be over 13,000 ZJ*. Of these, over 200 ZJ* would be extractable, with the potential to increase this to over 2,000 ZJ* with technology improvements - sufficient to provide all the world's present energy needs for several millennia."
So, EGS systems can today extract 200 Zettajoules of power from Geothermal. There's about 1 Zettajoule of energy hitting the Earth every hour from the sun. Also, in space, the concentration of solar radiation is 22 times HIGHER compared to on Earth... so, theoretically, aout 21 to 22 Zettajoules of energy is available in the solar system.
Considering that SF and the Federation do not have 'cost efficiency' and 'profits'... their technology is likely going to be built using superior synthetic materials that can be made in sustainable abundance with no damage to the environment and using state of the art science (Capitalism btw in real life doesn't do this).
This could indicate that SF can build their shipyards capable of generating massive amounts of energy from their hulls using nothing but Solar energy. Their solar capturing technology would be infinitely more advanced compared to ours, and would probably use a form of quantum dot technology which is atom based... and each would be able to capture and convert about 99% of power from solar. Now extrapolate this to the entire hull of a spacedock, and you have massive amounts of power for replicators and transporters.
If that isn't enough, both replicators and transporters can be used to directly manipulate matter on a subatomic scale (per Sf technological abilities).
In that sense, every ship equipped with transporters would theoretically be capable of self-sufficiency to never need to resupply from stations or trading (unless the technology is damaged to such a degree where it isn't possible to get it up an running without external aid).
Voyager's issue was consistently one of energy. Replicators were constantly rationed, though I cannot imagine as to why they never simply made a pit stop in an uninhabited star system, directly capture solar energy using their hull and shuffled this into their replicators for food, mountain of spare parts, creating new shuttles, etc, etc. etc.
Every SF ship would be able to set up a colony without cannibalizing anything on board (especially if the transporters are working, and they usually do).
As for how long it takes to build a ship... that was a problem with the writers who had 0 idea about technological progression, automation, etc. In short, their approach to automation technology for instance was mostly INEPT and downright 'hostile' even.
At any rate... I see no reason as to why SF simply doesn't replicate ships into existence. I agree a simple transporter system as seen on ships would be limited, but even it is capable of transporting a shuttle from space into a shuttlebay (we've seen it done on-screen).
Bottom line is: they CAN do it... and so much more. The writers on the other hand have little to no clue on how to handle such technology and setting, because they think it would take away from the 'drama'... whereas GOOD writers would actually write intelligently.
Trek did a lot of things right, but it also messed up a lot of things by doing things primitively (this is where the 'current day mentalities' could have been seen, even though a world of such an abundance and technology would likely generate a vastly different behaviour that would not be 'primitive').