A compilation-free loading method, device and medium for front-end engineering configuration files
By building and precompiling the configuration files to be loaded in front-end development and determining the loading method based on the content of the configuration file, the problem of recompilation of configuration file updates is solved, dynamic loading and real-time parsing are realized, and development efficiency is improved and system flexibility.
Patent Information
- Application Number
- CN202410655814.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-05-24
AI Technical Summary
During front-end development, configuration file updates and management require recompiling and packaging the entire application, resulting in reduced development efficiency and increased costs, especially in a rapidly iterative and continuous integration environment.
By building a preset configuration file to be loaded and precompiling it through the Node environment when the Vue project is started, we can determine whether there are window variables in the precompiled configuration file and determine the loading method to achieve dynamic loading and real-time parsing.
It realizes dynamic loading and real-time parsing of front-end engineering configuration files without recompiling the entire application, improving development efficiency and system flexibility, and reducing development costs and time costs.
Smart Images

Figure CN118567746B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software development technology, and in particular to a compilation-free loading method, device and medium for front-end engineering configuration files. Background Art
[0002] In the traditional front-end development process, the management and application of configuration files has always been an important link. These configuration files are usually compiled and packaged into the final application during the application build process. This processing method may not have obvious disadvantages during the initial build and deployment of the application, but it is a serious inconvenience in the subsequent configuration file update and management.
[0003] Specifically, once certain parameters in the configuration file need to be changed during development or operation and maintenance, such as adjusting the server interface address, modifying the application theme style, or optimizing performance-related configuration, the developer has to recompile and repackage the entire application. This process not only includes recompiling the code, but also involves multiple steps such as repackaging resource files, which is time-consuming and complex.
[0004] In addition, frequent recompiling and packaging of applications will also significantly reduce development efficiency. Especially in a development environment with rapid iteration and continuous integration, every minor adjustment of the configuration will trigger the rebuilding of the entire application, which will undoubtedly increase development costs and time costs, and is not conducive to the rapid advancement of the project and timely response to market needs.
[0005] Therefore, for the front-end engineering configuration file, how to achieve dynamic loading and real-time parsing without recompiling the entire application has become a technical problem that needs to be solved urgently. Summary of the invention
[0006] The embodiments of the present application provide a compilation-free loading method, device and medium for a front-end engineering configuration file, so as to solve the following technical problem: for a front-end engineering configuration file, how to realize dynamic loading and real-time parsing without recompiling the entire application.
[0007] In the first aspect, an embodiment of the present application provides a compilation-free loading method for a front-end engineering configuration file, characterized in that the method includes: constructing a corresponding configuration file to be loaded based on a preset configuration file deployment requirement; when a vue project corresponding to the configuration file to be loaded is started, precompiling the configuration file to be loaded through a Node environment; determining whether a window variable exists in a precompiled configuration file corresponding to the configuration file to be loaded, and determining a loading method to be applied based on the judgment result to load the precompiled configuration file.
[0008] In one implementation of the present application, the configuration file deployment requirements include: direct deployment requirements and containerized deployment requirements; based on the preset configuration file deployment requirements, the corresponding configuration file to be loaded is constructed, specifically including: when the configuration file deployment requirement is a direct deployment requirement, based on the preset configuration requirements, the required configuration items are stored in a preset independent configuration file in JSON format to obtain the configuration file to be loaded; when the configuration file deployment requirement is a containerized deployment requirement, based on the preset configuration requirements, the required configuration items are stored in a preset container configuration file to obtain the configuration file to be loaded.
[0009] In one implementation of the present application, when the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment, specifically including: in the startup phase of the vue project, running the precompiled script through the Node environment; reading the configuration file to be loaded based on the precompiled script, and converting the configuration file to be loaded into an executable precompiled configuration file.
[0010] In one implementation of the present application, after converting the configuration file to be loaded into an executable precompiled configuration file, the method further includes: injecting the precompiled configuration file into the global variables of the Vue project.
[0011] In one implementation of the present application, determining whether a window variable exists in a precompiled configuration file corresponding to a configuration file to be loaded specifically includes: scanning the JavaScript code in the precompiled configuration file through a regular expression; checking whether the JavaScript code contains a reference to or assignment operation to the window variable; if there is a reference to or assignment to the window variable, determining that the window variable exists in the precompiled configuration file; if there is no reference to or assignment to the window variable, determining that the window variable does not exist in the precompiled configuration file.
[0012] In one implementation of the present application, a loading method to be applied is determined based on the judgment result to load the precompiled configuration file, specifically including: when it is determined that there is a window variable in the precompiled configuration file, the precompiled configuration file is loaded through the require method; when it is determined that there is no window variable in the precompiled configuration file, the compiled configuration file is dynamically loaded through an XMLHttpRequest synchronous request.
[0013] In one implementation of the present application, after loading the precompiled configuration file, the method further includes: parsing the loaded precompiled configuration file using JavaScript; and when determining that a dynamic modification request is triggered, adjusting the precompiled configuration file in real time based on the request content of the dynamic modification request.
[0014] In one implementation of the present application, after the precompiled configuration file is adjusted in real time based on the request content of the dynamic modification request, the method also includes: recording a version of the adjusted precompiled configuration file; when version backtracking is required, retrieving the corresponding version of the precompiled configuration file based on the version record to backtrack to the corresponding version of the precompiled configuration file.
[0015] In the second aspect, an embodiment of the present application also provides a compilation-free loading device for a front-end engineering configuration file, characterized in that the device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: build a corresponding configuration file to be loaded based on preset configuration file deployment requirements; when the vue project corresponding to the configuration file to be loaded is started, precompile the configuration file to be loaded through the Node environment; determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied based on the judgment result to load the precompiled configuration file.
[0016] On the third aspect, the embodiment of the present application also provides a non-volatile computer storage medium for compiling and loading a front-end engineering configuration file, storing computer executable instructions, characterized in that the computer executable instructions are set to: build a corresponding configuration file to be loaded based on preset configuration file deployment requirements; when the vue project corresponding to the configuration file to be loaded is started, precompile the configuration file to be loaded through the Node environment; determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied based on the judgment result to load the precompiled configuration file.
[0017] The method, device and medium for compiling-free loading of a front-end engineering configuration file provided in the embodiments of the present application have the following beneficial effects:
[0018] 1. Flexibility and adaptability: This method can build corresponding configuration files to be loaded according to configuration file deployment requirements (including direct deployment and containerized deployment), so that it can flexibly adapt to different deployment environments and requirements.
[0019] 2. Pre-compilation optimization: When the Vue project is started, the configuration file to be loaded is pre-compiled through the Node environment, which can improve the loading speed and execution efficiency of the configuration file and reduce the performance loss during project operation.
[0020] 3. Intelligent loading mechanism: Determine the loading method by judging whether there is a window variable in the precompiled configuration file. This can not only ensure the correct loading of the configuration file, but also avoid using certain specific loading methods in unsuitable environments, thereby improving the stability and compatibility of the system.
[0021] 4. Global accessibility: Inject the precompiled configuration file into the global variables of the Vue project, so that the configuration file can be easily accessed and used anywhere in the project.
[0022] 5. Dynamic adjustment and real-time performance: During the project operation, the configuration file can be modified dynamically as needed, and the configuration content can be adjusted in real time, which greatly improves the flexibility and response speed of the system.
[0023] 6. Version management and backtracking: The adjusted configuration files are recorded and version backtracking is supported, which greatly facilitates configuration management and also helps track and troubleshoot problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0025] Figure 1 A flow chart of a method for compiling-free loading of a front-end engineering configuration file provided in an embodiment of the present application;
[0026] Figure 2 A schematic diagram of the internal structure of a compilation-free loading device for a front-end engineering configuration file provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0028] The embodiments of the present application provide a compilation-free loading method, device and medium for a front-end engineering configuration file, so as to solve the following technical problem: for a front-end engineering configuration file, how to realize dynamic loading and real-time parsing without recompiling the entire application.
[0029] The technical solution proposed in the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0030] Figure 1 A flow chart of a method for loading a front-end engineering configuration file without compilation provided in an embodiment of the present application. Figure 1 As shown, a method for compiling-free loading of a front-end engineering configuration file provided in an embodiment of the present application specifically includes the following steps:
[0031] Step 101: Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded.
[0032] First of all, it should be explained that there are generally two types of configuration file deployment requirements: direct deployment requirements and containerized deployment requirements.
[0033] In one embodiment of the present application, in order to realize compilation-free loading of the front-end engineering configuration file, it is first necessary to build the corresponding configuration file to be loaded based on the preset configuration file deployment requirements.
[0034] Specifically, when the configuration file deployment requirement is a direct deployment requirement, based on the preset configuration requirements, the required configuration items are stored in a preset independent configuration file in JSON format to obtain the configuration file to be loaded; when the configuration file deployment requirement is a containerized deployment requirement, based on the preset configuration requirements, the required configuration items are stored in a preset container configuration file to obtain the configuration file to be loaded.
[0035] In one embodiment, for direct deployment requirements, the configuration items required in the project are analyzed and determined. These configuration items may include but are not limited to API interface addresses, application theme colors, font sizes and other interface and function setting parameters. Based on these configuration items, an independent configuration file is created. To ensure the versatility and readability of the configuration, the JSON (JavaScript Object Notation) format is selected to store these configuration items. The JSON format is not only easy for humans to read and write, but also convenient for machines to parse and generate. All configuration items are written one by one into this independent configuration file according to the requirements of the JSON format. Each configuration item exists in the form of a key-value pair, the key represents the name of the configuration item, and the value represents the specific content of the configuration item. After completing the writing of the configuration file, save and name the file for subsequent loading operations.
[0036] In one embodiment, for containerized deployment requirements, the configuration items required in the project are also first analyzed and determined. Due to the characteristics of containerized deployment, these configuration items are stored directly in the container's configuration file instead of creating a separate file. The advantage of doing this is that it can be better integrated with the container environment and improve the flexibility and portability of the configuration. In the container configuration file, the configuration items are written one by one according to the specifications and requirements of the container. These configuration items may exist in the form of environment variables or may be stored in a specific configuration file format. After the configuration is completed, save and close the container configuration file. When the container starts, these configuration items will be automatically loaded into the application environment.
[0037] Step 102: When the Vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment.
[0038] In one embodiment of the present application, after the corresponding configuration file to be loaded is constructed, when the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment.
[0039] Specifically, during the startup phase of the Vue project, the precompiled script is run through the Node environment; the configuration file to be loaded is read based on the precompiled script, and the configuration file to be loaded is converted into an executable precompiled configuration file.
[0040] In one embodiment, these configuration files are precompiled through the Node environment. This process ensures the correctness and execution efficiency of the configuration files, and provides a solid foundation for the smooth operation of the Vue project. First, a script specifically for precompilation needs to be prepared. This script is usually written in Node.js because it can make full use of Node.js's asynchronous non-blocking I / O model and powerful ecosystem to efficiently process configuration files. When the Vue project is started, the previously prepared precompiled script is run through the Node environment. The first task of the precompiled script is to read the previously built configuration files to be loaded. These files may be located in a specific directory of the project, and the script locates and reads them through the file path. After reading the configuration file, the precompiled script will parse and process it. In this process, the script may perform complex operations such as variable replacement, conditional judgment, and function call to ensure that the content of the configuration file meets the actual operation requirements of the Vue project. After processing, the configuration file is converted into an executable precompiled configuration file. This file already contains all the necessary runtime information, and the format may be optimized so that it can be loaded and executed more efficiently by the Vue project.
[0041] In one embodiment of the present application, after the configuration file to be loaded is converted into an executable precompiled configuration file, the precompiled configuration file is injected into the global variables of the Vue project.
[0042] In one embodiment, the precompiled configuration file is injected into the global variables of the Vue project so that the configuration information can be easily accessed and used in any component or module in the project. First, a suitable global variable needs to be determined to store the contents of the precompiled configuration file. This global variable can be an attribute of the Vue instance or a global object created specifically for this purpose. Which method to choose depends on the specific needs and architecture of the project. Once the global variable is determined, the next step is to inject the contents of the precompiled configuration file into this global variable. This can usually be achieved by operating in the entry file of the Vue project (such as main.js or main.ts). Specifically, the precompiled configuration file can be imported in this file and assigned to the previously determined global variable. In order to ensure that the global variable is accessible throughout the Vue project, some additional steps may need to be taken. For example, if the properties of the Vue instance are used as global variables, then it is necessary to ensure that the Vue instance is accessible anywhere in the project. If a dedicated global object is used to store configuration information, it is necessary to ensure that this object is accessible anywhere in the project and its properties are not accidentally modified. Once the precompiled configuration file is successfully injected into the global variable, any component or module in the project can use the configuration information by accessing this global variable. This greatly simplifies the access and management of configuration information and improves the maintainability and readability of the code.
[0043] Step 103: determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied according to the determination result to load the precompiled configuration file.
[0044] In one embodiment of the present application, after the configuration file to be loaded is precompiled through the Node environment to obtain a precompiled configuration file, it is determined whether there is a window variable in the precompiled configuration file.
[0045] Specifically, the JavaScript code in the precompiled configuration file is scanned by a regular expression; it is checked whether the JavaScript code contains a reference to or an assignment operation to the window variable; if there is a reference to or an assignment to the window variable, it is determined that the window variable exists in the precompiled configuration file; if there is no reference to or assignment to the window variable, it is determined that the window variable does not exist in the precompiled configuration file.
[0046] In one embodiment, in order to scan the JavaScript code in the precompiled configuration file, it is first necessary to prepare one or more regular expressions, which can match the reference or assignment operation to the window variable. The specific form of the regular expression depends on the writing style of the JavaScript code and the possible use of the window variable. Using the prepared regular expression, the JavaScript code in the precompiled configuration file is scanned line by line. In this process, the regular expression will try to match any reference or assignment operation to the window variable. After the scan is completed, check whether the regular expression has matched any reference or assignment to the window variable. If the match is successful, it means that the use of the window variable does exist in the precompiled configuration file.
[0047] In one embodiment of the present application, after determining the judgment result, the loading method to be applied is determined according to the judgment result to load the precompiled configuration file.
[0048] Specifically, when it is determined that the window variable exists in the precompiled configuration file, the precompiled configuration file is loaded through the require method; when it is determined that the window variable does not exist in the precompiled configuration file, the compiled configuration file is dynamically loaded through an XMLHttpRequest synchronous request.
[0049] In one embodiment, if the judgment result shows that the window variable exists in the precompiled configuration file, this means that the configuration file may contain some code that depends on the browser environment. In this case, it is more appropriate to use the require method of Node.js to load the configuration file, because it can directly execute JavaScript code on the server side without considering the particularity of the browser environment. If the judgment result shows that the window variable does not exist in the precompiled configuration file, then the configuration file is independent of the environment and can be dynamically loaded through JavaScript on the browser side. In this case, it is appropriate to use XMLHttpRequest (or a more modern fetch API, selected according to the project compatibility requirements) for synchronous requests, because it allows asynchronous loading and execution of JavaScript code in the browser environment.
[0050] In one embodiment of the present application, after the precompiled configuration file is loaded, the loaded precompiled configuration file is parsed using JavaScript; when it is determined that a dynamic modification request is triggered, the precompiled configuration file is adjusted in real time based on the request content of the dynamic modification request.
[0051] In one embodiment, when it is determined that a dynamic modification request is triggered, the configuration file is adjusted in real time based on the request content. This process is intended to provide a flexible configuration management mechanism to adapt to changing application requirements. First, use JavaScript's JSON parsing method (such as JSON.parse) or other suitable parsing libraries to parse the loaded precompiled configuration file. Store the parsed configuration file content in a data structure that is easy to access and operate, such as an object or Map. Set a monitoring mechanism in the application to capture requests for dynamic modification of the configuration file. These requests may come from user interface operations, backend service calls or other triggers. The monitoring mechanism can be an HTTP interface, WebSocket connection, event listener or other real-time communication method, depending on the architecture and requirements of the application. Once a dynamic modification request is monitored, first verify the legitimacy and security of the request to ensure that only authorized operations can modify the configuration file. Parse the request content and extract the configuration items that need to be modified and their new values. According to the request content, locate the corresponding position in the data structure that stores the configuration file content. Update the configuration item value at this position to the new value in the request. If necessary, some additional logic can also be added to handle the side effects of configuration changes, such as reinitializing certain components, sending notifications, etc.
[0052] In one embodiment of the present application, after the precompiled configuration file is adjusted in real time based on the request content of the dynamic modification request, the method also includes: recording a version of the adjusted precompiled configuration file; and when version backtracking is required, retrieving the corresponding version of the precompiled configuration file based on the version record to backtrack to the corresponding version of the precompiled configuration file.
[0053] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, the embodiment of this application also provides a device, whose structure is as follows Figure 2 shown.
[0054] Figure 2 A schematic diagram of the internal structure of a front-end engineering configuration file provided in an embodiment of the present application without compiling and loading the device. Figure 2 As shown, the device includes:
[0055] at least one processor 201;
[0056] and, a memory 202 communicatively connected to the at least one processor;
[0057] The memory 202 stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor 201 to enable at least one processor 201 to:
[0058] Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded;
[0059] When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment;
[0060] It is determined whether the window variable exists in the precompiled configuration file corresponding to the configuration file to be loaded, and the loading method to be applied is determined according to the determination result to load the precompiled configuration file.
[0061] Some embodiments of the present application provide corresponding Figure 1 A non-volatile computer storage medium for front-end engineering configuration files that is free of compilation and loading, storing computer executable instructions, wherein the computer executable instructions are set as follows:
[0062] Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded;
[0063] When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment;
[0064] It is determined whether the window variable exists in the precompiled configuration file corresponding to the configuration file to be loaded, and the loading method to be applied is determined according to the determination result to load the precompiled configuration file.
[0065] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the IoT device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0066] The system and medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the system and medium also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.
[0067] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0068] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0069] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0071] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0072] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0073] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0074] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0075] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A compilation-free loading method for a front-end engineering configuration file, characterized in that: The method comprises: Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded; When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment; Determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied according to the determination result to load the precompiled configuration file; The configuration file deployment requirements include: direct deployment requirements and containerized deployment requirements; Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded, including: In the case where the configuration file deployment requirement is a direct deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset independent configuration file in JSON format to obtain the configuration file to be loaded; In the case where the configuration file deployment requirement is a containerized deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset container configuration file to obtain a configuration file to be loaded; According to the judgment result, the loading method to be applied is determined to load the precompiled configuration file, specifically including: When it is determined that the window variable exists in the precompiled configuration file, the precompiled configuration file is loaded through the require method; When it is determined that the window variable does not exist in the precompiled configuration file, the compiled configuration file is dynamically loaded through an XMLHttpRequest synchronous request.
2. A method for loading a front-end engineering configuration file without compilation according to claim 1, characterized in that: When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment, specifically including: At the startup stage of the Vue project, run the precompiled script through the Node environment; The configuration file to be loaded is read based on the precompiled script, and the configuration file to be loaded is converted into an executable precompiled configuration file.
3. A method for loading a front-end engineering configuration file without compilation according to claim 2, characterized in that: After converting the configuration file to be loaded into an executable precompiled configuration file, the method further includes: Inject the precompiled configuration file into the global variables of the Vue project.
4. A method for loading a front-end engineering configuration file without compilation according to claim 1, characterized in that: Determining whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded specifically includes: Scan the JavaScript code in the precompiled configuration file by using a regular expression; Check whether the JavaScript code contains a reference to or assignment operation on the window variable; If there is a reference or assignment to the window variable, it is determined that the window variable exists in the precompiled configuration file; If there is no reference or assignment to the window variable, it is determined that the window variable does not exist in the precompiled configuration file.
5. The method for loading a front-end engineering configuration file without compilation according to claim 1, characterized in that: After the precompiled configuration file is loaded, the method further comprises: Use JavaScript to parse the loaded precompiled configuration file; In the case where it is determined that a dynamic modification request is triggered, the precompiled configuration file is adjusted in real time based on the request content of the dynamic modification request.
6. A method for loading a front-end engineering configuration file without compilation according to claim 5, characterized in that: After adjusting the precompiled configuration file in real time based on the request content of the dynamic modification request, the method further includes: Recording the version of the adjusted precompiled configuration file; In the case where version backtracking is required, the precompiled configuration file of the corresponding version is retrieved based on the version record to backtrack to the precompiled configuration file of the corresponding version.
7. A compilation-free loading device for front-end engineering configuration files, characterized in that: The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded; When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment; Determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied according to the determination result to load the precompiled configuration file; The configuration file deployment requirements include: direct deployment requirements and containerized deployment requirements; Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded, including: In the case where the configuration file deployment requirement is a direct deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset independent configuration file in JSON format to obtain the configuration file to be loaded; In the case where the configuration file deployment requirement is a containerized deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset container configuration file to obtain a configuration file to be loaded; According to the judgment result, the loading method to be applied is determined to load the precompiled configuration file, specifically including: When it is determined that the window variable exists in the precompiled configuration file, the precompiled configuration file is loaded through the require method; When it is determined that the window variable does not exist in the precompiled configuration file, the compiled configuration file is dynamically loaded through an XMLHttpRequest synchronous request.
8. A non-volatile computer storage medium for front-end engineering configuration files that does not require compilation and loading, storing computer executable instructions, characterized in that: The computer executable instructions are configured to: Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded; When the vue project corresponding to the configuration file to be loaded is started, the configuration file to be loaded is precompiled through the Node environment; Determine whether there is a window variable in the precompiled configuration file corresponding to the configuration file to be loaded, and determine the loading method to be applied according to the determination result to load the precompiled configuration file; The configuration file deployment requirements include: direct deployment requirements and containerized deployment requirements; Based on the preset configuration file deployment requirements, build the corresponding configuration file to be loaded, including: In the case where the configuration file deployment requirement is a direct deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset independent configuration file in JSON format to obtain the configuration file to be loaded; In the case where the configuration file deployment requirement is a containerized deployment requirement, based on the preset configuration requirement, the required configuration items are stored in a preset container configuration file to obtain a configuration file to be loaded; According to the judgment result, the loading method to be applied is determined to load the precompiled configuration file, specifically including: When it is determined that the window variable exists in the precompiled configuration file, the precompiled configuration file is loaded through the require method; When it is determined that the window variable does not exist in the precompiled configuration file, the compiled configuration file is dynamically loaded through an XMLHttpRequest synchronous request.
Citation Information
Patent Citations
Interface display method and device, equipment and storage medium
CN112114807A
Environment variable updating method and device
CN116431374A