Webpack auxiliary configuration method, device, equipment and storage medium
By extracting and outputting the webpack configuration list, the webpack configuration process is simplified, solving the problems of tedious and unstable configurations, improving configuration efficiency and stability, and helping developers quickly locate and correct incorrect configuration items.
Patent Information
- Application Number
- CN202110984825.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-24
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-08-24
AI Technical Summary
Webpack configuration is cumbersome, costly and unstable, especially for different versions of webpack, especially webpack 3. A lot of time and effort is spent on finding the correct configuration solution, and there is a risk of unknown instability.
Provide an auxiliary configuration method for webpack. By extracting the target configuration fields and corresponding configuration values from the relevant files of the webpack tool, write the configuration list in association, and output the completed configuration list to the user, simplifying the configuration process and reducing manual search and During verification, clear configuration information is provided to facilitate developers to view and correct incorrect configuration items.
It saves developers time on configuration detection and improves the efficiency and stability of webpack configuration. By automatically extracting and outputting the configuration list, it provides clear configuration information, helping developers quickly locate and correct incorrect configuration items to ensure the stability of the project. sex.
Smart Images

Figure CN113626108B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet front-end technology, and in particular to a webpack auxiliary configuration method, device, equipment and storage medium. Background Art
[0002] With the vigorous development of front-end technology in recent years, the idea of modular development for large projects has become increasingly popular. As a modular packaging tool, webpack has also become popular. However, for different versions of webpack, especially webpack 3.x and above, the configuration of its own properties and related plug-ins and loaders is quite complicated, and the cost of getting started and configuration is high for many developers. In particular, the corresponding configuration scheme based on related plug-ins and loaders is not explained in detail by the official webpack, so developers need to find information on their own and find the correct configuration scheme through continuous settings and verification. The energy and time cost will be very high, and there is a risk of unknown instability through the ambiguous implementation scheme found. It can be seen that the current webpack configuration is not only cumbersome, but also has high configuration costs and uncertain configuration effects. Summary of the invention
[0003] In order to solve the technical problems of complicated webpack configuration, high configuration cost and unstable configuration effect in the prior art, the present application provides a webpack auxiliary configuration method, device, equipment and storage medium, the main purpose of which is to help developers sort out various configuration items of webpack and guide developers to correctly configure webpack.
[0004] To achieve the above purpose, the present application provides a webpack auxiliary configuration method, which includes:
[0005] Extract the target configuration fields and corresponding configuration values from the webpack-related files corresponding to the webpack tool. The target configuration fields include the basic configuration fields of webpack, the plug-in configuration fields corresponding to the webpack plug-in, and the loader configuration fields corresponding to the webpack loader.
[0006] Associate the target configuration fields and the corresponding configuration values into the configuration list;
[0007] Output the configuration list that has been written to the user.
[0008] In addition, to achieve the above purpose, the present application also provides an auxiliary configuration device for webpack, which includes:
[0009] The extraction module is used to extract the target configuration fields and corresponding configuration values from the webpack-related files corresponding to the webpack tool;
[0010] A writing module is used to associate the target configuration field and the corresponding configuration value and write it into the configuration list;
[0011] The output module is used to output the configuration list that has been written to the user.
[0012] To achieve the above objectives, the present application also provides a computer device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the steps of the webpack configuration assistance method as described in any of the preceding items are performed.
[0013] To achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the processor executes the steps of the auxiliary configuration method of webpack as described in any of the previous items.
[0014] The auxiliary configuration method, device, equipment and storage medium of webpack proposed in this application automatically extract data related to webpack configuration from webpack related files, write these data into the configuration list in a certain order, and output the configuration list that has been written, and the output configuration list is clear and readable. Users, such as developers, do not need to manually search for configuration items that need to be checked file by file in the project directory, thereby saving developers time for configuration detection. In addition, developers can clearly and systematically sort out and understand the project configuration under the action of webpack through the configuration list, which is convenient for developers to check, check and find out the configuration items to correct errors in a targeted manner, has a good guiding role, and guarantees the stability of their engineering projects to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is an application scenario diagram of the auxiliary configuration method of webpack in one embodiment of the present application;
[0016] Figure 2 This is a flow chart of an auxiliary configuration method of webpack in one embodiment of the present application;
[0017] Figure 3 This is a structural block diagram of an auxiliary configuration device of webpack in one embodiment of the present application;
[0018] Figure 4 This is a block diagram of the internal structure of a computer device in one embodiment of the present application.
[0019] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than 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 belong to the scope of protection of this application. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0021] The auxiliary configuration method of webpack provided in this application can be applied in Figure 1 In the application environment, the terminal device can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices.
[0022] Figure 2 This is a flow chart of the auxiliary configuration method of webpack in one embodiment of the present application. Figure 2 , this method is applied in Figure 1 The terminal device in is used as an example for explanation. The auxiliary configuration method of the webpack includes the following steps S100-S300.
[0023] S100: Extract target configuration fields and corresponding configuration values from webpack-related files corresponding to the webpack tool, wherein the target configuration fields include basic configuration fields of webpack, plug-in configuration fields corresponding to the webpack plug-in, and loader configuration fields corresponding to the webpack loader.
[0024] Specifically, webpack is used as a packager to package the project code of the project. The webpack-related files are located in the project directory of the project, which is similar to the directory of a folder. The project directory stores various files according to different functional file classifications and hierarchical relationships. The webpack-related files are part of the files under the project directory.
[0025] The auxiliary configuration method of webpack in this embodiment is implemented by the auxiliary configuration script of webpack. The auxiliary configuration script of webpack is written by the developer and runs in the computer independently of the project engineering, and does not need to be written into the project code of the project engineering. The auxiliary configuration script of webpack can be specifically a Python script, which defines the path to locate the target configuration field in the project directory, that is, which fields in which files in the project directory are used to extract the target configuration field.
[0026] The auxiliary configuration script of webpack runs in the computer, and extracts the target configuration field and the corresponding configuration value from the webpack configuration code of the webpack-related files in the project directory by executing the code logic of the script. The configuration value is the actual value of the target configuration field in the current webpack.
[0027] This application can be applied to scenarios such as webpack configuration and webpack upgrade. Webpack related files include: at least one of the following: webpack.xxx.config.js file, vue-loader.config.js file, .postcssrc.js file, package.json file, etc.
[0028] When developers write auxiliary configuration scripts for webpack, they will customize which target configuration fields need to be captured. Through auxiliary scripts, they can obtain basic configuration items, plugin configuration items, and loader configuration items of webpack from various webpack-related files. Among them, plugins and loaders are additional functions that can be added to or removed from webpack.
[0029] Among them, the basic configuration items of webpack include the basic configuration fields of webpack and their corresponding configuration values, the plug-in configuration items of webpack include the plug-in configuration fields and corresponding configuration values of each plug-in of webpack, and the loader configuration items of webpack include the loader configuration fields and corresponding configuration values of each loader of webpack.
[0030] In addition, webpack includes at least one plug-in and at least one loader, the plug-in configuration field of each plug-in includes at least one, and the loader configuration field of each loader includes at least one.
[0031] S200: writing the target configuration field and the corresponding configuration value into the configuration list in association.
[0032] Specifically, there are more than one target configuration fields, but often many. The purpose of writing the associated fields into the configuration list is to form a mapping relationship between each target configuration field and the corresponding configuration value, so that the data in the configuration list is distributed in an orderly manner, which is easy to read and increases readability.
[0033] S300: Outputting the configuration list that has been written to the user.
[0034] Specifically, the purpose of this embodiment is to automatically extract data related to the webpack configuration from webpack related files, write these data into the configuration list in a certain order, and output the completed configuration list. The completed configuration list refers to the configuration list after all the target configuration fields and corresponding configuration values are written. The configuration list after writing is clear and readable. Users, such as developers, do not need to manually search for configuration items that need to be checked file by file in the project directory, thereby saving developers time for configuration detection. In addition, developers can clearly understand the project configuration under the action of webpack through the configuration list, which is convenient for developers to view, check and find out the configuration items to correct errors in a targeted manner, and to a certain extent ensure the stability of their engineering projects.
[0035] In one embodiment, step S100 specifically includes:
[0036] Parse the first loader and the first configuration item corresponding to the first loader from the webpack.xxx.config.js file of the webpack related file, where the first configuration item includes the first target configuration field and the corresponding first configuration value;
[0037] Parse the postcssrc configuration item from the .postcssrc.js file of the webpack related file, where the postcssrc configuration item includes the second target configuration field and the corresponding second configuration value;
[0038] Parse the plugin variable, the plugin called by the plugin variable, and the third configuration item corresponding to the called plugin from the webpack.xxx.config.js file of the webpack related file, where the third configuration item includes the third target configuration field and the corresponding third configuration value;
[0039] Parse the second loader and the fourth configuration item corresponding to the second loader from the vue-loader.config.js file of the webpack related file, where the fourth configuration item includes a fourth target configuration field and a corresponding fourth configuration value;
[0040] Parse the fifth configuration item of the first loader, the sixth configuration item of the second loader, the seventh configuration item of the called plug-in, and the version of webpack from the package.json file of the webpack related files;
[0041] Among them, the fifth configuration item includes a fifth target configuration field and a corresponding fifth configuration value, the sixth configuration item includes a sixth target configuration field and a corresponding sixth configuration value, and the seventh configuration item includes a seventh target configuration field and a corresponding seventh configuration value.
[0042] Specifically, the first loader and the second loader are both loaders used by webpack. The first loader is a loader for some common functions, and the second loader is a loader such as Vue-loader.
[0043] The configuration code of the first loader is located through the "loader" field node in the webpack.xxx.config.js file of the webpack related file, the named field of the first loader is found, and the first target configuration field and the corresponding first configuration value at the same level as the named field of the first loader are parsed. Webpack includes at least one first loader, and each first loader includes at least one first target configuration field and a corresponding first configuration value.
[0044] The postcssrc configuration item corresponding to postcssrc includes the first postcssrc configuration item corresponding to the first loader and / or the second postcssrc configuration item corresponding to the second loader. The first postcssrc configuration item includes the first postcssrc configuration field and the corresponding first postcssrc configuration value, and the second postcssrc configuration item includes the second postcssrc configuration field and the corresponding second postcssrc configuration value.
[0045] The configuration code of the plug-in is located through the "pluins" field node in the webpack.xxx.config.js file of the webpack related file, the plug-in variable and the plug-in called by the plug-in variable are parsed, and the third configuration item at the same level as the plug-in variable and the corresponding third configuration value are parsed as the third configuration item of the corresponding called plug-in. Webpack includes at least one called plug-in, and each called plug-in includes at least one third configuration field and a corresponding third configuration value.
[0046] The configuration code of the second loader is located through the "Vue-loder" field node in the vue-loader.config.js file of the webpack related file, the naming field of the second loader is found, and the fourth target configuration field and the corresponding fourth configuration value at the same level as the naming field of the second loader are parsed. Webpack includes at least one second loader, and each second loader includes at least one fourth target configuration field and a corresponding fourth configuration value.
[0047] The fourth configuration field of the second loader includes fields such as cssSourceMap, cachBusting, and transformToRequire.
[0048] Get the keys and values, i.e., key-value pairs, in the dependencies object and devDependencies object from the package.json file of the webpack-related file, and parse out the webpack version. The dependencies object and devDependencies object respectively set the version numbers of all plug-ins, loaders, and webpack in the project. The key-value pairs obtained are the version numbers of plug-ins, loaders, and webpack. For example, "vue-loader":"^15.9.7" means that the version number of loaders such as Vue-loader is "^15.9.7". "mini-css-extract-plugin":"^0.12.0" means that the version number of plug-ins such as mini-css-extract-plugin is "^0.12.0". The fifth configuration item includes the name and version number of the first loader, the sixth configuration item includes the name and version number of the second loader Vue-loader, and the seventh configuration item includes the name and version number of the called plug-in. The version of Webpack is, for example, webpack3.x or webapck4.x, but is not limited to this.
[0049] In one embodiment, the method further comprises:
[0050] Get the standard configuration file corresponding to the webpack version from the preset knowledge base;
[0051] Compare the written configuration list with the standard configuration file to obtain the difference items;
[0052] Obtaining a corresponding first solution from a knowledge base according to the difference item;
[0053] The difference items and the corresponding first solutions are returned to the user.
[0054] Specifically, the knowledge base includes the standard configuration file corresponding to each webpack version, which includes the version of the plug-in, the version of the loader, the standard configuration value of each configuration field of each plug-in, the standard configuration value of each configuration field of each loader, the standard configuration value of each configuration field in the webpack internal configuration, and so on.
[0055] The knowledge base is a reference knowledge base formed by continuous project debugging, a large amount of practical verification of webpack project engineering, and summary and classification of official documents from authoritative official websites and by developers based on the debugging process.
[0056] During the debugging process, we continuously run and upgrade the project and debug various configuration items until all errors and warnings are resolved. The running project is verified by the npm runbuild / dev script, so that the size of the project file after webpack packaging is significantly reduced, the source code after packaging is consistent with the current project configuration, the packaged files after running the project can run normally in the browser, and the project running in the browser is faster than before the upgrade.
[0057] According to the standard configuration file, the difference items in the completed configuration list can be automatically and quickly found, and the first solution corresponding to the difference items can be matched. The first solution is obtained according to the standard configuration value of the configuration field in the annotation configuration file. The first solution is specifically a modification plan or suggestion. Developers can quickly locate problems in the actual webpack configuration based on the difference items and the corresponding first solution, and correct the wrong configuration. The configuration efficiency of webpack is greatly improved.
[0058] In addition, the difference items can be identified in the written configuration list, and the corresponding first solution can be added, and then the configuration list with the identification added can be provided to the developer as a guide file.
[0059] The standard configuration files in the knowledge base can effectively help developers quickly locate the incorrect configurations that have not been found manually in the configuration list, and help developers review the correctness of the webpack configuration again. Help developers complete the configuration or upgrade of webpack.
[0060] In one embodiment, the method further comprises:
[0061] Get the current error log output after running the webpack reconfigured according to the first solution under the project;
[0062] Obtain a second solution corresponding to the current error log from historical error logs and warning logs and corresponding solutions in the knowledge base;
[0063] Return the current error log and the corresponding second solution to the user.
[0064] Specifically, the current error log is output by vscode, so the specific error log content will be output through the vscode window. The webpack auxiliary configuration script can obtain and analyze the current error log content by directly accessing the file location of the current error log, or copy the current error log to a new file, and then execute the python script code to parse the content in the new file.
[0065] The written configuration list is the initial configuration of webpack made by the developer based on experience. The purpose of checking the written configuration list against the standard configuration file is to automatically and quickly check the developer's webpack configuration so as to correct the wrong webpack configuration in time before running the project. Since the operating environment of the project is complex and uncontrollable, the standard configuration file cannot fully guarantee the detection of all wrong configurations in the written configuration list. Therefore, the webpack reconfigured by the developer according to the first solution may also report errors during operation.
[0066] The knowledge base also stores historical error logs, warning logs and corresponding solutions. Therefore, by comparing the error log with the historical error log and warning log in the knowledge base, unreasonable configuration or error information can be found, and the corresponding second solution can be output at the same time. The second solution is provided to users such as developers, and developers can quickly locate and correct the wrong configuration of webpack according to the second solution. Especially in the webpack upgrade process, this embodiment can quickly and efficiently solve the error problem, so that the engineering project can run correctly. The purpose of comparing the configuration and knowledge base in the current project is to retrieve a large amount of reliable upgrade or configuration essential knowledge and error handling solutions summarized by consulting a large amount of knowledge based on error or warning information in the current project. For example: plug-in, loader version number, configuration, modification method of replacing abandoned plug-ins with new plug-ins, etc. At the same time, the detailed configuration information of webpack configuration, plug-in and loader comes from authoritative official websites.
[0067] The knowledge base is also a template for reliable solutions that have been categorized. In the process of a large number of practical verifications of webpack projects, the knowledge base has also collected and summarized a large amount of reliable upgrade essential knowledge and error handling solutions. During the verification process, developers will also write or supplement the solutions to the knowledge base based on the errors or warnings obtained. For example, under a certain version of webpack, what are the limitations of certain plug-ins or loader versions, how to modify new plug-ins to replace abandoned plug-ins, etc.
[0068] In addition, you can identify the wrong configuration items in the completed configuration list according to the current error log, add the corresponding second solution, and then provide the configuration list with the identification added as the error log solution to the developer. Developers can use the second solution to set specific configuration items in the webpack of the project, and finally achieve rapid project upgrades. The upgraded project will be more reliable than the traditional solution searched on the Internet.
[0069] In one embodiment, before step S300, the method further includes:
[0070] Obtain the target annotation corresponding to the target configuration field from the preset knowledge base;
[0071] Write the target annotation as an annotation association to the corresponding target configuration field in the configuration manifest.
[0072] Specifically, after writing the annotations to the configuration values of the corresponding target configuration fields in the configuration list, it is easier for developers to understand the configuration information of webpack, and it has a good prompt and explanation effect for developers to use webpack to run engineering projects. As an annotated configuration list, it can help developers familiarize themselves with the project in detail, and then know what the specific configuration items are for during the upgrade or configuration process, which is helpful to improve the configuration plan based on the current project situation and have a clear understanding of it.
[0073] The knowledge base contains webpack versions and the available versions of corresponding loaders and plug-ins, the configuration fields and standard configuration values of loaders and plug-ins under each available version, error problems in the upgrade process and the solutions and annotations provided, and annotations corresponding to each configuration field. By matching keywords in the knowledge base, the corresponding webpack configuration description, loader, and plug-in configuration information are output. The knowledge base also includes various configuration annotations for webpack. As an annotated configuration list, it can help developers familiarize themselves with the project in detail, and then know what the specific configuration items are for during the upgrade or configuration process, which is conducive to improving the configuration plan in combination with the current project situation and having a clear idea in mind. According to the standard configuration files in the knowledge base, it can effectively help developers quickly locate the error configurations that have not been found manually in the written configuration list, and help developers to review the correctness of the webpack configuration again. Help developers complete the upgrade of webpack. At the same time, if errors and warning prompts appear during the webpack upgrade process, a solution can be output by analyzing the error log and warning log. Developers can use the solution to set specific configuration items to the webpack of the project. Finally, a fast project upgrade is achieved, and the upgraded project will be more reliable than the traditional solution searched on the Internet.
[0074] In one embodiment, step S100 further includes:
[0075] Parse the devtool field and its corresponding configuration value, output field and its corresponding configuration value, mode field and its corresponding configuration value, optimization field and its corresponding configuration value, DevServer field and its corresponding configuration value, and node field and its corresponding configuration value from other nodes at the same level as the module node. Among them, the module node and other nodes at the same level as the module node are all nodes in the webpack.xxx.config.js file of the webpack related file.
[0076] Specifically, the devtool field and its corresponding configuration value, output field and its corresponding configuration value, mode field and its corresponding configuration value, optimization field and its corresponding configuration value, DevServer field and its corresponding configuration value, and node field and its corresponding configuration value are all internal basic configuration fields of webpack, and are configuration fields in other nodes at the same level as the module node.
[0077] In one embodiment, the postcssrc configuration item includes a first postcssrc configuration item corresponding to the first loader and a second postcssrc configuration item corresponding to the second loader;
[0078] The first postcssrc configuration item includes a first postcssrc configuration field and a corresponding first postcssrc configuration value, and the second postcssrc configuration item includes a second postcssrc configuration field and a corresponding second postcssrc configuration value.
[0079] Specifically, the postcssrc configuration item is used to configure the loader. Therefore, the postcssrc configuration item includes some postcssrc configuration fields and postcssrc configuration values of the first loader and the second loader.
[0080] In one embodiment, step S200 specifically includes:
[0081] Write the first target configuration field and the corresponding first configuration value of the first loader, the first postcssrc configuration field and the corresponding first postcssrc configuration value, the fifth target configuration field and the corresponding fifth configuration value into a first Json object and write them into the configuration list;
[0082] The third target configuration field and the corresponding third configuration value, the seventh target configuration field and the corresponding seventh configuration value of the called plug-in are composed into a second JSon object and written into the configuration list;
[0083] Write the third Json object composed of the fourth target configuration field and the corresponding fourth configuration value of the second loader, the second postcssrc configuration field and the corresponding second postcssrc configuration value, the sixth target configuration field and the corresponding sixth configuration value into the configuration list;
[0084] The webpack field and the corresponding webpack version, devtool field and the corresponding configuration value, output field and the corresponding configuration value, mode field and the corresponding configuration value, optimization field and the corresponding configuration value, DevServer field and the corresponding configuration value, node field and the corresponding configuration value form the fourth Json object and write it into the configuration list.
[0085] Specifically, this embodiment writes the relevant configuration items of the internal configuration of the loader, plug-in, and webpack into the configuration list in the form of Json objects in different categories. Among them, the first Json object of the first loader and the third Json object of the second loader can be written to adjacent positions in the configuration list. Each first loader or second loader or plug-in includes a Json object, each Json object contains at least one key-value pair, and each key-value pair is a target configuration field and a corresponding configuration value.
[0086] Using Json format to write configuration fields and configuration values into the configuration list is not only convenient for developers to consult, but also helps to parse and check whether the configuration values in the configuration list are correct.
[0087] In a specific embodiment, the auxiliary configuration script of webpack extracts target configuration fields and configuration values such as basic configuration fields of webpack, plugin configuration fields of webpack plugins, and loader configuration fields of webpack loaders from webpack related files corresponding to the webpack tool; obtains target annotations corresponding to target configuration fields from a preset knowledge base; and writes target configuration fields, corresponding configuration values, and target annotations into a configuration list. Output an annotated configuration list to developers so that they can manually check whether there are erroneous configuration items based on the annotated configuration list, and timely change and correct webpack configuration or project configuration.
[0088] The auxiliary configuration script of webpack will also obtain the standard configuration file corresponding to the version of webpack from the preset knowledge base; compare the completed configuration list with the standard configuration file to obtain the difference items; obtain the corresponding first solution from the knowledge base based on the difference items; identify the difference items in the completed configuration list and add the corresponding first solution, and output the identified and added configuration list to the developer, so that the developer can modify the incorrect configuration items in webpack according to this new configuration list with guidance.
[0089] The auxiliary configuration script of webpack will also obtain the current error log output after running the webpack reconfigured according to the first solution under the project; obtain the second solution corresponding to the current error log from the historical error log and warning log of the knowledge base and the corresponding solution; and return the current error log and the corresponding second solution to the user. Of course, the current error log and the corresponding second solution can also be added to the configuration list, and the current error log and the corresponding second solution can be returned to the developer in the form of a configuration list.
[0090] The annotated configuration list allows developers to clearly understand the project configuration and determine whether there are problems with the existing webpack configuration through self-checking. The guide file can quickly, efficiently and automatically check whether there are problems with the modified configuration file, and point out the wrong configuration and provide relevant configuration solutions for developers. The error log processing guide file can efficiently and quickly analyze the error problems in the error log, and provide solutions to the error problems, further improving the webpack configuration. In the webpack configuration, especially the webpack upgrade process, the knowledge base-based webpack configuration ensures the stability of the project.
[0091] Collect and organize the knowledge points related to webpack in an orderly manner, and provide them to developers to verify whether there are problems or vulnerabilities in the initial configuration of webpack. When there are problems, provide developers with wrong configurations and corresponding solutions so that developers can improve and correct the webpack configuration.
[0092] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0093] Figure 3 This is a structural block diagram of an auxiliary configuration device of webpack in one embodiment of the present application; the auxiliary configuration device of Webpack includes:
[0094] The extraction module 100 is used to extract the target configuration field and the corresponding configuration value from the webpack related files corresponding to the webpack tool, wherein the target configuration field includes the basic configuration field of the webpack, the plug-in configuration field corresponding to the webpack plug-in and the loader configuration field corresponding to the webpack loader;
[0095] A writing module 200 is used to write the target configuration field and the corresponding configuration value into the configuration list in association;
[0096] The output module 300 is used to output the configuration list that has been written to the user.
[0097] In one embodiment, the extraction module 100 includes:
[0098] A first extraction unit is used to parse a first loader and a first configuration item corresponding to the first loader from a webpack.xxx.config.js file of a webpack-related file, where the first configuration item includes a first target configuration field and a corresponding first configuration value;
[0099] A second extraction unit is used to parse a postcssrc configuration item from a .postcssrc.js file of a webpack-related file, where the postcssrc configuration item includes a second target configuration field and a corresponding second configuration value;
[0100] A third extraction unit is used to parse the plug-in variable, the plug-in called by the plug-in variable, and the third configuration item corresponding to the called plug-in from the webpack.xxx.config.js file of the webpack related file, where the third configuration item includes a third target configuration field and a corresponding third configuration value;
[0101] A fourth extraction unit is used to parse the second loader and a fourth configuration item corresponding to the second loader from the vue-loader.config.js file of the webpack related file, where the fourth configuration item includes a fourth target configuration field and a corresponding fourth configuration value;
[0102] A fifth extraction unit, used for parsing the fifth configuration item of the first loader, the sixth configuration item of the second loader, the seventh configuration item of the called plug-in and the version of webpack from the package.json file of the webpack related files;
[0103] Among them, the fifth configuration item includes a fifth target configuration field and a corresponding fifth configuration value, the sixth configuration item includes a sixth target configuration field and a corresponding sixth configuration value, and the seventh configuration item includes a seventh target configuration field and a corresponding seventh configuration value.
[0104] In one embodiment, the apparatus further comprises:
[0105] The first matching module is used to obtain a standard configuration file corresponding to the webpack version from a preset knowledge base;
[0106] A first comparison module is used to compare the written configuration list with the standard configuration file to obtain the difference items;
[0107] A second matching module, used for acquiring a corresponding first solution from a knowledge base according to the difference item;
[0108] The second output module is used to return the difference item and the corresponding first solution to the user.
[0109] In one embodiment, the apparatus further comprises:
[0110] The log capture module is used to obtain the current error log output after running the webpack reconfigured according to the first solution in the project;
[0111] A third matching module is used to obtain a second solution corresponding to the current error log from the historical error logs and warning logs and corresponding solutions in the knowledge base;
[0112] The third output module is used to return the current error log and the corresponding second solution to the user.
[0113] In one embodiment, the apparatus further comprises:
[0114] A fourth matching module, used to obtain a target annotation corresponding to a target configuration field from a preset knowledge base;
[0115] Annotation module, used to write target annotations into the configuration manifest as annotation associations for corresponding target configuration fields.
[0116] In one embodiment, the extraction module 100 further includes:
[0117] Parse the devtool field and its corresponding configuration value, output field and its corresponding configuration value, mode field and its corresponding configuration value, optimization field and its corresponding configuration value, DevServer field and its corresponding configuration value, and node field and its corresponding configuration value from other nodes at the same level as the module node. Among them, the module node and other nodes at the same level as the module node are all nodes in the webpack.xxx.config.js file of the webpack related file.
[0118] In one embodiment, the postcssrc configuration item includes a first postcssrc configuration item corresponding to the first loader and a second postcssrc configuration item corresponding to the second loader;
[0119] The first postcssrc configuration item includes a first postcssrc configuration field and a corresponding first postcssrc configuration value, and the second postcssrc configuration item includes a second postcssrc configuration field and a corresponding second postcssrc configuration value;
[0120] The writing module 200 includes:
[0121] Write the first target configuration field and the corresponding first configuration value of the first loader, the first postcssrc configuration field and the corresponding first postcssrc configuration value into a first Json object and write them into the configuration list;
[0122] The third target configuration field of the called plug-in and the corresponding third configuration value are combined into a second JSON object and written into the configuration list;
[0123] Write the fourth target configuration field and the corresponding fourth configuration value of the second loader, the second postcssrc configuration field and the corresponding second postcssrc configuration value of the second loader into a third Json object and write it into the configuration list;
[0124] Write the fifth target configuration field of the first loader and the corresponding fifth configuration value, the seventh target configuration field of the called plug-in and the corresponding seventh configuration value, the sixth target configuration field of the second loader and the corresponding sixth configuration value, and the webpack version into the fourth Json object into the configuration list;
[0125] The devtool field and its corresponding configuration value, output field and its corresponding configuration value, mode field and its corresponding configuration value, optimization field and its corresponding configuration value, DevServer field and its corresponding configuration value, and node field and its corresponding configuration value form a fifth Json object and write it into the configuration list.
[0126] The meaning of "first" and "second" in the above modules / units is only to distinguish different modules / units, and is not used to define which module / unit has a higher priority or other limiting meanings. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The division of modules in this application is only a logical division, and there may be other division methods when implemented in actual applications.
[0127] For the specific definition of the auxiliary configuration device of webpack, please refer to the definition of the auxiliary configuration method of webpack above, which will not be repeated here. Each module in the above-mentioned auxiliary configuration device of webpack can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0128] Figure 4 This is a block diagram of the internal structure of a computer device in one embodiment of the present application. The computer device may specifically be Figure 1 The terminal device in. Figure 4As shown, the computer device includes a processor, a memory, a network interface, an input device and a display screen connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory includes a storage medium and an internal memory. The storage medium can be a non-volatile storage medium or a volatile storage medium. The storage medium stores an operating system and can also store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can implement the auxiliary configuration method of webpack. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the storage medium. Computer-readable instructions can also be stored in the internal memory. When the computer-readable instructions are executed by the processor, the processor can execute the auxiliary configuration method of webpack. The network interface of the computer device is used to communicate with an external server through a network connection. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse.
[0129] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions (such as a computer program) stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the steps of the auxiliary configuration method of webpack in the above embodiment are implemented, such as Figure 2 Steps S100 to S300 and other extensions of the method and related steps are shown. Alternatively, when the processor executes the computer-readable instructions, the functions of each module / unit of the auxiliary configuration device of webpack in the above embodiment are realized, for example Figure 3 The functions of the modules 100 to 300 are shown in detail and will not be described again to avoid repetition.
[0130] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of a computer device, and uses various interfaces and lines to connect various parts of the entire computer device.
[0131] The memory can be used to store computer-readable instructions and / or modules. The processor implements various functions of the computer device by running or executing the computer-readable instructions and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.), etc.
[0132] The memory may be integrated into the processor or provided separately from the processor.
[0133] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0134] In one embodiment, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the steps of the auxiliary configuration method of webpack in the above embodiment are implemented, such as Figure 2 Steps S100 to S300 and other extensions of the method and related steps are shown. Alternatively, when the computer-readable instructions are executed by the processor, the functions of each module / unit of the auxiliary configuration device of webpack in the above embodiment are realized, for example Figure 3 The functions of the modules 100 to 300 are shown in detail and will not be described again to avoid repetition.
[0135] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0136] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method 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, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.
[0137] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. Through the description of the above implementation modes, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases the former is a better implementation mode. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, including a number of instructions to enable a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0138] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A webpack auxiliary configuration method, characterized in that: The method comprises: Extract the target configuration field and the corresponding configuration value from the webpack related files corresponding to the webpack tool, wherein the target configuration field includes the basic configuration field of webpack, the plug-in configuration field corresponding to the webpack plug-in, and the loader configuration field corresponding to the webpack loader; Writing the target configuration field and the corresponding configuration value into the configuration list; Output the configuration list that has been written to the user; The target configuration field and the corresponding configuration value are extracted from the webpack related files corresponding to the webpack tool, including: Parse the first loader and the first configuration item corresponding to the first loader from the webpack.xxx.config.js file of the webpack related file, where the first configuration item includes a first target configuration field and a corresponding first configuration value; Parse the postcssrc configuration item from the postcssrc.js file of the webpack related file, wherein the postcssrc configuration item includes the second target configuration field and the corresponding second configuration value; Parse the plugin variable, the plugin called by the plugin variable, and the third configuration item corresponding to the called plugin from the webpack.xxx.config.js file of the webpack related file, wherein the third configuration item includes a third target configuration field and a corresponding third configuration value; Parse the second loader and the fourth configuration item corresponding to the second loader from the vue-loader.config.js file of the webpack related file, wherein the fourth configuration item includes a fourth target configuration field and a corresponding fourth configuration value; Parse the fifth configuration item of the first loader, the sixth configuration item of the second loader, the seventh configuration item of the called plug-in, and the version of the webpack from the package.json file of the webpack related file; Among them, the fifth configuration item includes a fifth target configuration field and a corresponding fifth configuration value, the sixth configuration item includes a sixth target configuration field and a corresponding sixth configuration value, and the seventh configuration item includes a seventh target configuration field and a corresponding seventh configuration value.
2. The method according to claim 1, characterized in that The method further comprises: Obtain a standard configuration file corresponding to the webpack version from a preset knowledge base; Compare the written configuration list with the standard configuration file to obtain difference items; Acquire a corresponding first solution from the knowledge base according to the difference item; The difference item and the corresponding first solution are returned to the user.
3. The method according to claim 2, characterized in that The method further comprises: Get the current error log output after running the webpack reconfigured according to the first solution in the project; Acquire a second solution corresponding to the current error log from historical error logs and warning logs of the knowledge base and corresponding solutions; The current error log and the corresponding second solution are returned to the user.
4. The method according to claim 1, characterized in that: Before outputting the configuration list that has been written to the user, the method further includes: Obtaining the target annotation corresponding to the target configuration field from a preset knowledge base; The target annotation is written into the configuration manifest as an annotation association of a corresponding target configuration field.
5. The method according to claim 1, characterized in that The method of extracting the target configuration field and the corresponding configuration value from the webpack related file corresponding to the webpack tool also includes: The devtool field and the corresponding configuration value, output field and the corresponding configuration value, mode field and the corresponding configuration value, optimization field and the corresponding configuration value, DevServer field and the corresponding configuration value, and node field and the corresponding configuration value are parsed from other nodes at the same level as the module node, wherein the module node and other nodes at the same level as the module node are all nodes in the webpack.xxx.config.js file of the webpack related file.
6. The method according to claim 5, characterized in that The postcssrc configuration item includes a first postcssrc configuration item corresponding to the first loader and a second postcssrc configuration item corresponding to the second loader; The first postcssrc configuration item includes a first postcssrc configuration field and a corresponding first postcssrc configuration value, and the second postcssrc configuration item includes a second postcssrc configuration field and a corresponding second postcssrc configuration value; The step of associating the target configuration field and the corresponding configuration value and writing them into the configuration list includes: Write the first target configuration field and the corresponding first configuration value of the first loader, the first postcssrc configuration field and the corresponding first postcssrc configuration value into a first Json object and write them into the configuration list; Write the third target configuration field of the called plug-in and the corresponding third configuration value into a second Json object and write it into the configuration list; Write the third Json object composed of the fourth target configuration field and the corresponding fourth configuration value of the second loader, the second postcssrc configuration field and the corresponding second postcssrc configuration value into the configuration list; Write the fifth target configuration field and the corresponding fifth configuration value of the first loader, the seventh target configuration field and the corresponding seventh configuration value of the called plug-in, the sixth target configuration field and the corresponding sixth configuration value of the second loader, and the fourth Json object composed of the webpack version into the configuration list; The devtool field and the corresponding configuration value, the output field and the corresponding configuration value, the mode field and the corresponding configuration value, the optimization field and the corresponding configuration value, the DevServer field and the corresponding configuration value, and the node field and the corresponding configuration value form a fifth Json object and write it into the configuration list.
7. A Webpack auxiliary configuration device, the device is used to implement the webpack auxiliary configuration method according to any one of claims 1 to 6, characterized in that: The device comprises: An extraction module is used to extract target configuration fields and corresponding configuration values from webpack-related files corresponding to the webpack tool, wherein the target configuration fields include basic configuration fields of webpack, plugin configuration fields corresponding to webpack plugins, and loader configuration fields corresponding to webpack loaders; A writing module, used to write the target configuration field and the corresponding configuration value into the configuration list in association; The first output module is used to output the configuration list that has been written to the user.
8. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer-readable instructions, the processor performs the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer readable instructions are executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 6.
