Compared with the conventional method utilizing permanent processing facilities, modular infrastructure has shown greater potential to hedge against the uncertainty due to the rapidly declining characteristic of shale gas production. However, there is still a lack of a comprehensive approach that integrates the production planning and the dynamic allocation of the modular infrastructure based on the production curve of shale gas wells. Therefore, a systematic optimization framework is developed to simultaneously optimize the production planning and modular infrastructure allocation over a given time horizon, maximizing the net present value (NPV) of the system, considering the production curve and gas well status, the processing capacity as well as the scheduling of modular infrastructure. The proposed mixed-integer linear programming model combines the decisions relevant to shale gas production, transportation, and processing together with the decisions regarding modular infrastructure, including allocation, capacity selection, installment planning, moving scheduling, and salvage operation. A case study deciding a development strategy for 24 multi-well pads over a period of 15 years is implemented to illustrate the applicability of the proposed model. The results show that the dynamic allocation of the modular infrastructure can adapt to productivity fluctuations. The use of the modular approach increases the NPV by 9.12% and has a high utilization efficiency of processing devices compared to the conventional method. This work reveals that the synergistic interaction of the production planning and modular infrastructure dynamic allocation can increase efficiencies in the uses of energy, resources, and human capital to promote cleaner production practices.