Dynamically load css files based on domain name

there are multiple platforms under a vue project. The style of which platform is loaded is determined according to the domain name accessed by the customer, and most of the js, are universal, so we can only extract the uncommon ones into separate files, such as a.css and b.css. We intend to dynamically load a file and import it in the form of variables on the page, but how to achieve dynamic loading and what kind of directory structure is better

Nov.15,2021

you can use js to dynamically generate script and link tags in index.html


create a webpack configuration file for each platform with webpack, and each file sets configuration items according to requirements. When deploying, use the corresponding webpack configuration file according to the platform. (the condition is that each platform corresponds to a separate server. )

Menu