CN110286917A - File packing method, device, equipment and storage medium - Google Patents

File packing method, device, equipment and storage medium Download PDF

Info

Publication number
CN110286917A
CN110286917A CN201910433071.3A CN201910433071A CN110286917A CN 110286917 A CN110286917 A CN 110286917A CN 201910433071 A CN201910433071 A CN 201910433071A CN 110286917 A CN110286917 A CN 110286917A
Authority
CN
China
Prior art keywords
file
packaged
packing
item
packaging
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910433071.3A
Other languages
Chinese (zh)
Inventor
王冬扬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Priority to CN201910433071.3A priority Critical patent/CN110286917A/en
Publication of CN110286917A publication Critical patent/CN110286917A/en
Priority to PCT/CN2019/120921 priority patent/WO2020233057A1/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Abstract

The present invention relates to software technology, a kind of file packing method, device, equipment and storage medium are disclosed, this method comprises: treating packed items file carries out packing analysis, judge in packed items file with the presence or absence of item file can be optimized;Corresponding packing optimization tool is then obtained if it exists, and carries out being packaged acquisition packaging file to that can optimize item file according to optimization tool is packaged;Packing compression is carried out to remaining item file, and the packing compressed file of acquisition is merged with packaging file, obtain target packaging file, due to being first to carry out packing analysis, then optimizable item file is determined whether there is based on the analysis results, packing is then optimized to that can optimize item file according to packing optimization tool if it exists, and then it can targetedly be packaged to item file can be optimized, even if item file can individually be optimized by, which occurring, is packaged the packing compression for unsuccessfully nor affecting on alternative document, so as to shorten file packaging time length, improve packaging efficiency.

Description

File packing method, device, equipment and storage medium
Technical field
The present invention relates to field of computer technology more particularly to a kind of file packing method, device, equipment and storage to be situated between Matter.
Background technique
With the fast development of computer software technology, it is indispensable that various types of software applications have become popular life A part.In some scenarios, the corresponding each functional module of software application needs to carry out packing compression.Existing application The packaging method of file is usually all using a kind of webpack (application program when carrying out being packaged compression to software application Static module packing device) tool is general to the application file that is packaged of needs is packaged, when the file body that needs are packaged When product is larger, packaging efficiency will have a greatly reduced quality, and cause to take a long time, once the case where reporting an error, it is necessary to it re-starts Secondary packing, disadvantage are obvious.
Above content is only used to facilitate the understanding of the technical scheme, and is not represented and is recognized that above content is existing skill Art.
Summary of the invention
The main purpose of the present invention is to provide a kind of file packing method, device, equipment and storage mediums, it is intended to solve Certainly the prior art is when carrying out application file packing, low efficiency, the technical issues of time-consuming.
To achieve the above object, it the present invention provides a kind of file packing method, the described method comprises the following steps:
It obtains to packed items file, be packaged analysis to packed items file to described to obtain analysis result;
Item file can be optimized to whether there is in packed items file according to analysis result judgement is described;
If it exists, then it can optimize the corresponding packing optimization tool of item file described in obtaining, and be optimized by the packing Tool is packaged the item file that optimizes, and obtains packaging file;
Packing compression is carried out to remaining item file in packed items file to described, and text is compressed into the packing of acquisition Part is merged with the packaging file, obtains target packaging file.
Preferably, described to obtain to packed items file, be packaged analysis to packed items file to described to obtain Before the step of analyzing result, which comprises
When receiving file packing instruction, extracts the file and be packaged the file format mark in instruction included;
Include the item file of file format mark according to the file format identifier lookup, and will find Item file is used as to packed items file;
It is described to obtain to packed items file, be packaged analysis to packed items file to described to obtain analysis result The step of, comprising:
It obtains to packed items file, whether the described detection to the corresponding file size of packed items file is more than default text Part size;
If being more than, calls default file to be packaged analysis tool and be packaged analysis to packed items file to described to obtain Take analysis result.
Preferably, the corresponding packing optimization tool of item file can be optimized described in the acquisition, and excellent according to the packing The step of chemical industry tool is packaged the item file that optimizes, obtains packaging file, comprising:
The corresponding target file type of item file can be optimized described in acquisition, in the file type constructed in advance and be packaged excellent The corresponding packing optimization tool of the target file type is searched in mapping relations between chemical industry tool;
By searching for packing optimization tool the item file that optimizes is packaged, obtain packaging file.
Preferably, it is described by searching for packing optimization tool the item file that optimizes is packaged, obtain Before the step of packaging file, the method also includes:
The corresponding number of types of the target file type is counted, detects whether the number of types is more than preset quantity;
If being no more than, using single thread operating mechanism execute it is described by searching for the packing optimization tool arrived to it is described can The step of optimization item file is packaged, obtains packaging file.
Preferably, the corresponding number of types of the statistics target file type, detects whether the number of types surpasses After the step of crossing preset quantity, the method also includes:
If being more than, preconfigured multithreading plug-in unit is called to execute parallel described by searching for the packing optimization tool arrived The step of item file that optimizes is packaged, packaging file is obtained.
Preferably, the item file that optimizes includes cascading style list file;
It is described by searching for packing optimization tool the item file that optimizes is packaged, obtain packaging file The step of, comprising:
The corresponding current file size of the cascading style list file is obtained, and detects whether the current file size surpasses Cross preset threshold;
When the current file size is more than the preset threshold, default file is called to be packaged plug-in unit to the stacking sample Formula list file is packaged, and packaging file is obtained.
Preferably, the item file that optimizes further includes vue file;
It is described by searching for packing optimization tool the item file that optimizes is packaged, obtain packaging file The step of, comprising:
The corresponding file destination size of the vue file is obtained, and detects whether the file destination size is more than default Numerical value;
When the file destination size is more than the default value, the current file version of the vue file is obtained, and Detect whether the current file version belongs to exploitation version;
If belonging to, default version conversion plug-in unit is called to carry out version conversion to the vue file, and will be after version conversion File as packaging file.
In addition, to achieve the above object, the present invention also proposes a kind of file packing apparatus, described device includes:
It is packaged analysis module, for obtaining to packed items file, carries out packing analysis to packed items file to described Result is analyzed to obtain;
File judgment module, for described to which whether there is in packed items file can be excellent according to analysis result judgement Change item file;
When for that can optimize item file described in presence, it is corresponding can to optimize item file for file packetization module described in acquisition Packing optimization tool, and the item file that optimizes is packaged by the packings optimization tool, obtain be packaged it is literary Part;
File combination module, for carrying out packing compression to remaining item file in packed items file to described, and The packing compressed file of acquisition is merged with the packaging file, obtains target packaging file.
In addition, to achieve the above object, the present invention also proposes a kind of file baling equipment, the equipment include: memory, The file that processor and being stored in can be run on the memory and on the processor is packaged program, and the file is packaged journey Sequence is arranged for carrying out the step of file packing method as described above.
In addition, to achieve the above object, the present invention also proposes a kind of storage medium, file is stored on the storage medium It is packaged program, the file is packaged the step of realizing file packing method as described above when program is executed by processor.
The present invention treats packed items file and carries out being packaged analysis to obtain analysis knot by obtaining to packed items file Fruit;Judge that item file can be optimized to whether there is in packed items file based on the analysis results;If it exists, then obtaining can optimize The corresponding packing optimization tool of item file, and be packaged according to optimization tool is packaged to item file can be optimized, it is beaten APMB package;Treat remaining item file in packed items file and carry out packing compression, and by the packing compressed file of acquisition with Packaging file merges, and obtains target packaging file, due to being first to carry out packing analysis to file, then based on the analysis results The item file that can optimize is determined whether there is, if it exists then according to preconfigured packing optimization tool to project can be optimized File optimizes packing, can targetedly be packaged to can optimize item file, even if there is single optimize Item file is packaged the packing compression for the case where failure nor affecting on alternative document, so as to shorten file packaging time length, raising File packaging efficiency.
Detailed description of the invention
Fig. 1 is the structural schematic diagram of the file baling equipment for the hardware running environment that the embodiment of the present invention is related to;
Fig. 2 is the flow diagram of file packing method first embodiment of the present invention;
Fig. 3 is the flow diagram of file packing method second embodiment of the present invention;
Fig. 4 is the flow diagram of file packing method 3rd embodiment of the present invention;
Fig. 5 is the structural block diagram of file packing apparatus first embodiment of the present invention.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that described herein, specific examples are only used to explain the present invention, is not intended to limit the present invention.
Referring to Fig.1, Fig. 1 is the file baling equipment structural representation for the hardware running environment that the embodiment of the present invention is related to Figure.
As shown in Figure 1, this document baling equipment may include: processor 1001, such as central processing unit (Central Processing Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, memory 1005.Wherein, Communication bus 1002 is for realizing the connection communication between these components.User interface 1003 may include display screen (Display), input unit such as keyboard (Keyboard), optional user interface 1003 can also include that the wired of standard connects Mouth, wireless interface.Network interface 1004 optionally may include standard wireline interface and wireless interface (such as Wireless Fidelity (WIreless-FIdelity, WI-FI) interface).Memory 1005 can be the random access memory (Random of high speed Access Memory, RAM) memory, be also possible to stable nonvolatile memory (Non-Volatile Memory, ), such as magnetic disk storage NVM.Memory 1005 optionally can also be the storage device independently of aforementioned processor 1001.
It will be understood by those skilled in the art that structure shown in Fig. 1 does not constitute the restriction to file baling equipment, it can To include perhaps combining certain components or different component layouts than illustrating more or fewer components.
As shown in Figure 1, as may include operating system, data storage mould in a kind of memory 1005 of storage medium Block, network communication module, Subscriber Interface Module SIM and file are packaged program.
In file baling equipment shown in Fig. 1, network interface 1004 is mainly used for logical with network server progress data Letter;User interface 1003 is mainly used for carrying out data interaction with user;Processor 1001 in file baling equipment of the present invention is deposited Reservoir 1005 can be set in file baling equipment, and the file baling equipment calls memory 1005 by processor 1001 The file of middle storage is packaged program, and executes file packing method provided in an embodiment of the present invention.
It is file packing method of the present invention the referring to Fig. 2, Fig. 2 the embodiment of the invention provides a kind of file packing method The flow diagram of one embodiment.
In the present embodiment, the file packing method the following steps are included:
Step S10: it obtains to packed items file, carries out being packaged analysis to obtain analysis to packed items file to described As a result;
It should be noted that the executing subject of the present embodiment method can be with data processing, network communication and journey Calculating service equipment or terminal, such as tablet computer, PC of sort run function etc. (hereinafter referred to as packing terminal).It is described It can be the application code file for carrying out being packaged compression to packed items file.The present embodiment is applied to be based on The code file of webpack is packaged scene, and the optimization of packing process is carried out primarily directed to existing webpack packaging technique.
It should be understood that the webpack is the static module packing device of a modern times JavaScript application program (module bundler).When webpack handles application program, it can recursively construct a dependence graph (dependency graph), wherein all these modules are then packaged into one comprising each module that application program needs A or multiple bundle.
It is understood that under normal conditions, webpack can be for different resource type (or text in packing process Part type) it is handled using different loader, then all static resources are integrated into a bundle.One is applied Due to code file functions of modules or the difference of resource type for program, detailed process when packing is not also identical, Mou Xiezi The code file of Source Type can carry out packing process optimization in packing process to improve packaging efficiency.Therefore, this reality It applies example and can first treat the item file of packing in packing process and carry out packing analysis, then finding out based on the analysis results can be into The step of row packing process optimizes or item file.
In the concrete realization, item file to be packaged can first be obtained by being packaged terminal, then by being packaged analysis tool pair It is described be packaged analysis to packed items file to obtain analysis result.
Step S20: described to literary with the presence or absence of project can be optimized in packed items file according to analysis result judgement Part;
It should be understood that the file that the project of webpack+vue is packaged out is often several easily in practical packing process Hundred kilobytes (Kilobyte, Kb) even upper million, tracing it to its cause has: being packaged cascading style sheets (Cascading Style Sheets, CSS) file when, webpack can directly be bundled to literal translation formula scripting language together as module In (JavaScript, JS) file;All JS module+dependences (i.e. the relating module of JS module) are all bundled to a text Part;Vue file is excessive.And the file of actually these types can all carry out packing process optimization, therefore the present embodiment It is packaged situation in conjunction with practical, the file of above-mentioned three types can be optimized into item file as described in.Certainly, institute in the present embodiment Item file can be optimized by, which stating, does not limit to and above-mentioned three class file.
In the concrete realization, it is packaged terminal and treats packed items file and carry out packing by being packaged analysis tool and analysis and obtain After taking analysis result, it can inquire upper no comprising optimizable item file, such as CSS file, JS mould in the analysis result Block+dependence and/or vue file etc..
Step S30: if it exists, then it can optimize the corresponding packing optimization tool of item file described in acquisition, and by described It is packaged optimization tool to be packaged the item file that optimizes, obtains packaging file;
It should be noted that it is described be packaged optimization tool and can be developer and be directed in advance different optimize project text The packing optimization tool or plug-in unit of part configuration, such as by extract-text-webpack-plugin plug-in unit come to CSS file It is packaged, executes new webpack.optimize.CommonsChunkPlugin (' common.js') function to extract public affairs It is total to the production version that code is packaged, switches vue file by webpack.DefinePlugin plug-in unit, to reduce vue The file size etc. of file.
In the concrete realization, terminal is packaged to determine according to the analysis result got to exist in packed items file It is above-mentioned to be gone to search corresponding packing optimization tool according to these item files when optimizing item file, then according to obtaining These packing optimization tools got are packaged file.
Further, it is contemplated that the resource type of the integrated code file of different application programs and code file is not It is identical to the greatest extent, but the corresponding packing process of file of same asset type is all similar, and optimization tool is also about the same, to improve File packaging efficiency can be established between a file type and corresponding packing optimization tool in being packaged terminal in the present embodiment Mapping relations so that being packaged terminal is determining that it is targeted when optimizing item file that this file is packaged, by obtaining The file type that can optimize item file is taken, then rapidly and accurately obtained according to above-mentioned mapping relations and calls corresponding beat Packet optimization tool.
It should be noted that for the ease of above-mentioned to the subsequent dynamic modification of mapping relations progress or update, the present embodiment The file type and the corresponding interrelational form for being packaged optimization tool that item file can be optimized in mapping relations can pass through key assignments Pair mode realize, such as " key=value ", wherein " key " can be can optimize item file file type (such as CSS file, JS module+dependence, vue file etc.), " value " then can be preconfigured packing optimization tool or plug-in unit (example Such as, extract-text-webpack-plugin plug-in unit, new webpack.optimize.CommonsChunkPlugin (' Common.js') function and webpack.DefinePlugin plug-in unit etc.).
Specifically, be packaged terminal can obtain it is described can optimize the corresponding target file type of item file, constructed in advance File type and the mapping relations that are packaged between optimization tool in search corresponding packings of the target file type and optimize work Tool;Then the item file that optimizes is packaged according to the packing optimization tool found, obtains packaging file.
In addition, item file pair can be optimized getting by being packaged terminal to further increase packaging efficiency, in the present embodiment After the target file type answered, the corresponding number of types of the target file type (such as target file type packet will be also counted CSS file, vue file are included, then the number of types is 2), to detect whether the number of types is more than preset quantity;If not surpassing Cross, then using single thread operating mechanism execute it is described by searching for packing optimization tool to it is described optimize item file into The step of row is packaged, and obtains packaging file;If being more than, preconfigured multithreading plug-in unit " webpack-parallel- is called Uglify-plugin " execute parallel it is described by searching for packing optimization tool the item file that optimizes is beaten The step of packet, acquisition packaging file.
Step S40: packing compression, and beating acquisition are carried out to remaining item file in packed items file to described Packet compressed file is merged with the packaging file, obtains target packaging file.
It should be noted that the present embodiment, which is packaged terminal, can wait for each the progress of packed items file can optimize project File and the division that item file can not be optimized, then to can optimize item file according to preconfigured packing optimization tool into Row is packaged, and carries out normal packing compression to that can not optimize item file, both packing manners can carry out simultaneously, thus into one Step improves packaging efficiency.
Wherein, described to optimize item file, i.e., in packed items file except it is described optimize item file in addition to Remaining item file.It is further to note that can not optimize item file described in the present embodiment not being is always can not Optimization, developer can also be certain in item file for that can not optimize according to the actual situation during subsequent applications File carries out being packaged optimization analysis and configures corresponding strapping tool, then optimizes project text for these files as new Part.
In the concrete realization, packing terminal can treat remaining item file in packed items file and carry out packing compression, And merge the packing compressed file of acquisition with packaging file, obtain final packed target packaging file.
The present embodiment treats packed items file and carries out being packaged analysis to obtain analysis by obtaining to packed items file As a result;Judge that item file can be optimized to whether there is in packed items file based on the analysis results;If it exists, then obtaining can be excellent Change the corresponding packing optimization tool of item file, and be packaged according to optimization tool is packaged to item file can be optimized, is obtained Packaging file;It treats remaining item file in packed items file and carries out packing compression, and by the packing compressed file of acquisition It is merged with packaging file, obtains target packaging file, due to being first to carry out packing analysis to file, then tied according to analysis Fruit determines whether there is the item file that can optimize, if it exists then according to preconfigured packing optimization tool to can optimize item Mesh file optimizes packing, and then can targetedly be packaged to can optimize item file, even if single can be excellent The packing that change item file packing unsuccessfully nor affects on alternative document improves packaging efficiency so as to shorten packaging time length.
With reference to Fig. 3, Fig. 3 is the flow diagram of file packing method second embodiment of the present invention.
Based on above-mentioned first embodiment, in the present embodiment, before the step S10, the method also includes:
Step S01: it when receiving file packing instruction, extracts the file and is packaged the file format mark in instruction included Know;
It should be noted that the file, which is packaged instruction, can be carrying to the corresponding file format mark of packed items file The request command of knowledge.Wherein, the file format mark can be the type or type that can be used to characterize data exchange format Character information, common data interchange format has JSON (JavaScript Object Notation), XML (eXtensible Markup Language), YAML (Yet Another Markup Language) etc., institute in the present embodiment Stating file format mark can be the english abbreviation of the above-mentioned data interchange format such as JSON, XML, YAML.
In addition, user can be packaged instruction " webpack--profile-- by input file on being packaged terminal in the present embodiment Json > stats.json ", certain this document, which is packaged instruction, can also trigger generation by timed task preset in packing terminal.
In the concrete realization, be packaged terminal receive file be packaged instruction " webpack--profile--json > When stats.json ", it can extract the file format mark " json " for including in the instruction, then obtained according to this document format identification (FID) Take the corresponding file of this packaging operation.
Step S02: including the item file of the file format mark according to the file format identifier lookup, and will The item file found is used as to packed items file;
It should be understood that JavaScript is a kind of scripting language for belonging to network, has been widely used for Web application and open Hair is commonly used to add miscellaneous dynamic function for webpage, provides the result of browse of more smooth beauty for user.In view of certain Under a little special scenes, needs to separate the js file for including in application program's code file, terminal is packaged in the present embodiment It, can be in application code text to be packaged after extracting file and being packaged the file format mark " json " in instruction included Searched in part include this document format identification (FID) item file, i.e., then the files of all json formats will find The json file item file to be packaged as this.
Correspondingly, the step S10, it may include:
Step S101: obtaining to packed items file, detection it is described to the corresponding file size of packed items file whether More than default file size;
It should be understood that, it is contemplated that the file size of different application is different from, biggish for file size to answer It can be reduced really with program using the file packing manner in first embodiment and be packaged the time, improve packaging efficiency;But for The lesser application program of file size, if still item file can be optimized using the analysis lookup in first embodiment, according to opening The mode that the packing optimization tool of hair personnel depaly carries out packaging operation respectively will have development cost increase, aggravate exploit person The problem of member's workload.
In order to overcome the problems referred above, the present embodiment is packaged terminal when getting the item file wait be packaged, first described in acquisition To the file size of packed items file, then detect whether the file size is more than that (specific value is or not default file size Limit), corresponding subsequent operation is executed further according to testing result.
Step S102: it if being more than, calls default file to be packaged analysis tool and is beaten to packed items file described Packet analysis is to obtain analysis result.
It should be noted that the default file strapping tool can be the website with webpack file analysis function, Such as " webpack/analyse ", " Webpack Chart ".
Specifically, detecting to the corresponding file size of packed items file to be more than that the default file is big if being packaged terminal It is small, then show that file size is excessive, will will lead to that packaging efficiency is low to ask according to the general direct mode for being packaged compression Topic can call default file to be packaged analysis tool at this time and carry out being packaged analysis to obtain analysis to packed items file to described As a result.
If being packaged terminal and detecting and be no more than the default file size to the corresponding file size of packed items file, Showing file size not is that very greatly, more efficient instead by the way of being directly packaged compression, being packaged terminal at this time can treat Packed items file directly carries out packing compression, to obtain compressed file.
For the present embodiment when receiving file packing instruction, extraction document is packaged the file format mark in instruction included; It include the item file of file format mark according to file format identifier lookup, and using the item file found as wait beat Packet item file;It obtains to packed items file, whether detection is more than default text to the corresponding file size of packed items file Part size;If being more than, calls default file to be packaged analysis tool and treat packed items file and be packaged analysis to obtain point Analysis as a result, by thus according to the file size to packaging file come which kind of packaging operation of Predicated execution, compared to it is existing directly Be packaged the mode of All Files, can it is more practical, effectively carry out packaging operation, improve packaging efficiency.
With reference to Fig. 4, Fig. 4 is the flow diagram of file packing method 3rd embodiment of the present invention.
Based on the various embodiments described above, in the present embodiment, the item file that optimizes includes cascading style list file;Phase Ying Di, it is described by searching for packing optimization tool the item file that optimizes is packaged, obtain packaging file Step, it may include:
Step S301: the corresponding current file size of the cascading style list file is obtained, and detects the current file Whether size is more than preset threshold;
It should be noted that existing webpack often directly makees these files when being packaged CSS file It is bundled in js file together for a module, for this kind of situation, if being packaged plug-in unit " extract- using default file Text-webpack-plugin " is packaged the compiling that will generate the longer time to CSS file, also replaces without module heat (Hot Module Replacement, HMR), also will increase additional hypertext transfer protocol (HyperText Transfer Protocol, HTTP) request, therefore the present embodiment considers that one threshold value (the i.e. described preset threshold) of setting is come so that being packaged terminal When the file size for detecting CSS file is not very big (being no more than the preset threshold), it is packaged and inserts without using this document Part.
In the concrete realization, terminal is packaged when detecting described can optimize in item file including CSS file, obtains institute The corresponding current file size of CSS file is stated, and detects whether the current file size is more than the preset threshold.
Step S302: when the current file size is more than the preset threshold, default file is called to be packaged plug-in unit pair The cascading style list file is packaged, and packaging file is obtained.
If being packaged terminal detects that the current file size is more than the preset threshold, calls default file to be packaged and insert Part " extract-text-webpack-plugin " is packaged CSS file, obtains packaging file.
Further, in this embodiment the item file that optimizes may also include vue file;Correspondingly, described to pass through The step of packing optimization tool found is packaged the item file that optimizes, and obtains packaging file, it may include:
Step: obtaining the corresponding file destination size of the vue file, and detect the file destination size whether be more than Default value;
It should be understood that vue file described in the present embodiment can be, by vue.js, (a set of building user interface is gradually Into formula frame) creation file.Similarly, it is contemplated that the file size for the vue file that each application program includes is different from, To improve packaging efficiency as far as possible, the present embodiment uses different processing modes to the vue file of different file sizes.
In this step, the corresponding target text of the vue file that can optimize and include in item file can first be obtained by being packaged terminal Then part size detects whether the file destination size is more than default value;The vue file is directly sent out if being no more than The content distributing network (Content Delivery Network, CDN) being sent to where corresponding application program background server In cached.
Step: when the file destination size is more than the default value, the current file version of the vue file is obtained This, and detect whether the current file version belongs to exploitation version;
It should be understood that under normal conditions, being wrapped in the vue file for the exploitation version that developer uses in the case where developing environment Production version containing many code annotations or warning message etc., but in actual deployment to line does not need above-mentioned code annotation and police then Accuse information.Therefore, it is packaged terminal in the present embodiment when detecting that vue file is excessive, version detection can be carried out to it, with determination Whether the vue file currently got is to belong to exploitation version.
Step: if belonging to, calling default version conversion plug-in unit to carry out version conversion to the vue file, and by version File after conversion is as packaging file.
In this step, terminal is packaged when the current file version for detecting the vue file belongs to exploitation version, i.e., Version conversion plug-in unit " webpack.DefinePlugin " can be preset to vue file progress version conversion by calling, and Using the file after version conversion as packaging file, to accelerate packaging efficiency while reducing file size.
The present embodiment treats the CSS file for often including in packed items file and vue file carries out being packaged respectively Cheng Youhua improves packing rate of these files in packing process, effectively shortens and is packaged the time.
In addition, the embodiment of the present invention also proposes a kind of storage medium, it is stored with file on the storage medium and is packaged program, The file is packaged the step of realizing file packing method as described above when program is executed by processor.
It is the structural block diagram of file packing apparatus first embodiment of the present invention referring to Fig. 5, Fig. 5.
As shown in figure 5, the file packing apparatus that the embodiment of the present invention proposes includes:
It is packaged analysis module 501, for obtaining to packed items file, carries out packing point to packed items file to described Analysis is to obtain analysis result;
File judgment module 502, for described to whether there is in packed items file according to analysis result judgement Item file can be optimized;
File packetization module 503 when for that can optimize item file described in presence, can optimize item file pair described in acquisition The packing optimization tool answered, and the item file that optimizes is packaged by the packing optimization tool, it is packaged File;
File combination module 504, for carrying out packing compression to remaining item file in packed items file to described, And merge the packing compressed file of acquisition with the packaging file, obtain target packaging file.
The present embodiment treats packed items file and carries out being packaged analysis to obtain analysis by obtaining to packed items file As a result;Judge that item file can be optimized to whether there is in packed items file based on the analysis results;If it exists, then obtaining can be excellent Change the corresponding packing optimization tool of item file, and be packaged according to optimization tool is packaged to item file can be optimized, is obtained Packaging file;It treats remaining item file in packed items file and carries out packing compression, and by the packing compressed file of acquisition It is merged with packaging file, obtains target packaging file, due to being first to carry out packing analysis to file, then tied according to analysis Fruit determines whether there is the item file that can optimize, if it exists then according to preconfigured packing optimization tool to can optimize item Mesh file optimizes packing, and then can targetedly be packaged to can optimize item file, even if single can be excellent The packing that change item file packing unsuccessfully nor affects on alternative document improves packaging efficiency so as to shorten packaging time length.
Based on the above-mentioned file packing apparatus first embodiment of the present invention, propose that the second of file packing apparatus of the present invention is implemented Example.
In the present embodiment, the packing analysis module 501 is also used to extract institute when receiving file packing instruction It states file and is packaged the file format mark in instruction included;It include the file format according to the file format identifier lookup The item file of mark, and using the item file found as to packed items file;It obtains to packed items file, detection Whether described to the corresponding file size of packed items file be more than default file size;If being more than, default file is called to beat Packet analysis tool be packaged analysis to packed items file to described to obtain analysis result.
Further, the file packetization module 503, being also used to obtain described can optimize the corresponding target text of item file Part type searches the target file type in the file type constructed in advance and the mapping relations being packaged between optimization tool Corresponding packing optimization tool;By searching for packing optimization tool the item file that optimizes is packaged, obtain Packaging file.
Further, the file packetization module 503 is also used to count the corresponding number of types of the target file type Amount, detects whether the number of types is more than preset quantity;If being no more than, pass through using described in the execution of single thread operating mechanism The packing optimization tool found is packaged the item file that optimizes, and obtains the operation of packaging file.
Further, the file packetization module 503 is also used to detecting that the number of types is more than the present count When amount, call preconfigured multithreading plug-in unit execute parallel it is described by searching for packing optimization tool optimize to described Item file is packaged, and the operation of packaging file is obtained.
Further, the file packetization module 503, be also used to obtain the cascading style list file is corresponding ought be above Part size, and detect whether the current file size is more than preset threshold;It is more than described default in the current file size When threshold value, calls default file to be packaged plug-in unit and the cascading style list file is packaged, obtain packaging file.
Further, the file packetization module 503 is also used to obtain the corresponding file destination size of the vue file, And detect whether the file destination size is more than default value;When the file destination size is more than the default value, The current file version of the vue file is obtained, and detects whether the current file version belongs to exploitation version;If belonging to, Default version conversion plug-in unit is then called to carry out version conversion to the vue file, and using the file after version conversion as packing File.
The other embodiments or specific implementation of file packing apparatus of the present invention can refer to above-mentioned each method embodiment, this Place repeats no more.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the system that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or system institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or system.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in a storage medium In (such as read-only memory/random access memory, magnetic disk, CD), including some instructions are used so that a terminal device (can To be mobile phone, computer, server, air conditioner or the network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of file packing method, which is characterized in that the described method includes:
It obtains to packed items file, be packaged analysis to packed items file to described to obtain analysis result;
Item file can be optimized to whether there is in packed items file according to analysis result judgement is described;
If it exists, then it can optimize the corresponding packing optimization tool of item file described in obtaining, and pass through the packing optimization tool The item file that optimizes is packaged, packaging file is obtained;
Carry out packing compression to remaining item file in packed items file to described, and by the packing compressed file of acquisition with The packaging file merges, and obtains target packaging file.
2. the method as described in claim 1, which is characterized in that the acquisition is to packed items file, to the item to be packaged Mesh file be packaged before the step of analysis is to obtain analysis result, which comprises
When receiving file packing instruction, extracts the file and be packaged the file format mark in instruction included;
It include the item file of file format mark according to the file format identifier lookup, and the project that will be found File is used as to packed items file;
It is described to obtain to packed items file, it carries out being packaged step of the analysis to obtain analysis result to packed items file to described Suddenly, comprising:
It obtains to packed items file, whether the described detection to the corresponding file size of packed items file is more than that default file is big It is small;
If being more than, calls default file to be packaged analysis tool and be packaged analysis to packed items file to described to obtain point Analyse result.
3. the method as described in claim 1, which is characterized in that it is excellent that the corresponding packing of item file can be optimized described in the acquisition Chemical industry tool, and the step of item file that optimizes is packaged, packaging file is obtained by the packing optimization tool, Include:
The corresponding target file type of item file can be optimized described in acquisition, in the file type constructed in advance and be packaged optimization work The corresponding packing optimization tool of the target file type is searched in mapping relations between tool;
By searching for packing optimization tool the item file that optimizes is packaged, obtain packaging file.
4. method as claimed in claim 3, which is characterized in that it is described by searching for the packing optimization tool arrived to it is described can be excellent Before changing the step of item file is packaged, obtains packaging file, the method also includes:
The corresponding number of types of the target file type is counted, detects whether the number of types is more than preset quantity;
If being no more than, using single thread operating mechanism execute it is described by searching for packing optimization tool optimize to described The step of item file is packaged, and packaging file is obtained.
5. method as claimed in claim 4, which is characterized in that described to count the corresponding number of types of the target file type Amount, after detecting the step of whether number of types is more than preset quantity, the method also includes:
If being more than, call preconfigured multithreading plug-in unit execute parallel it is described by searching for the packing optimization tool arrived to institute The step of item file can be optimized by, which stating, is packaged, and packaging file is obtained.
6. method as described in claim 4 or 5, which is characterized in that the item file that optimizes includes cascading style sheets text Part;
It is described by searching for packing optimization tool the item file that optimizes is packaged, obtain the step of packaging file Suddenly, comprising:
The corresponding current file size of the cascading style list file is obtained, and detects whether the current file size is more than pre- If threshold value;
When the current file size is more than the preset threshold, default file is called to be packaged plug-in unit to the cascading style sheets File is packaged, and packaging file is obtained.
7. method as claimed in claim 6, which is characterized in that the item file that optimizes further includes vue file;
It is described by searching for packing optimization tool the item file that optimizes is packaged, obtain the step of packaging file Suddenly, comprising:
The corresponding file destination size of the vue file is obtained, and detects whether the file destination size is more than default value;
When the file destination size is more than the default value, the current file version of the vue file is obtained, and detect Whether the current file version belongs to exploitation version;
If belonging to, default version conversion plug-in unit is called to carry out version conversion to the vue file, and by the text after version conversion Part is as packaging file.
8. a kind of file packing apparatus, which is characterized in that described device includes:
It is packaged analysis module, for obtaining to packed items file, be packaged analysis to packed items file to described to obtain Take analysis result;
File judgment module, for item can be optimized to whether there is in packed items file according to analysis result judgement is described Mesh file;
File packetization module when for that can optimize item file described in presence, can optimize that item file is corresponding to be beaten described in acquisition Packet optimization tool, and the item file that optimizes is packaged according to the packing optimization tool, obtain packaging file;
File combination module for carrying out packing compression to remaining item file in packed items file to described, and will obtain The packing compressed file obtained is merged with the packaging file, obtains target packaging file.
9. a kind of file baling equipment, which is characterized in that the equipment includes: memory, processor and is stored in the storage On device and the file that can run on the processor is packaged program, and the file is packaged program and is arranged for carrying out such as claim The step of file packing method described in any one of 1 to 7.
10. a kind of storage medium, which is characterized in that be stored with file on the storage medium and be packaged program, the file is packaged The step of file packing method as described in any one of claim 1 to 7 is realized when program is executed by processor.
CN201910433071.3A 2019-05-21 2019-05-21 File packing method, device, equipment and storage medium Pending CN110286917A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910433071.3A CN110286917A (en) 2019-05-21 2019-05-21 File packing method, device, equipment and storage medium
PCT/CN2019/120921 WO2020233057A1 (en) 2019-05-21 2019-11-26 File packaging method, apparatus and device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910433071.3A CN110286917A (en) 2019-05-21 2019-05-21 File packing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110286917A true CN110286917A (en) 2019-09-27

Family

ID=68002485

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910433071.3A Pending CN110286917A (en) 2019-05-21 2019-05-21 File packing method, device, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN110286917A (en)
WO (1) WO2020233057A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111046311A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Method and device for realizing traceless iteration version of PC (personal computer) end, computer equipment and storage medium
CN111045654A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Vue-based method and device for quickly generating common instructions, computer equipment and storage medium
CN111176628A (en) * 2019-12-19 2020-05-19 福建天泉教育科技有限公司 Front-end access method under modular architecture and storage medium
CN111240684A (en) * 2020-01-03 2020-06-05 北京字节跳动网络技术有限公司 Cutting method and device of JS code, medium and electronic equipment
CN111724133A (en) * 2020-06-19 2020-09-29 北京达佳互联信息技术有限公司 Method and device for creating project
CN111966639A (en) * 2020-08-27 2020-11-20 恒为科技(上海)股份有限公司 Generating and processing method and device for PCB production file
WO2020233057A1 (en) * 2019-05-21 2020-11-26 深圳壹账通智能科技有限公司 File packaging method, apparatus and device, and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1139883C (en) * 2001-08-20 2004-02-25 北京九州计算机网络有限公司 Intelligent compression method for file of computer
US20110167173A1 (en) * 2010-01-05 2011-07-07 International Business Machines Corporation Optimal Compression Process Selection Methods
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
US20130275396A1 (en) * 2012-04-11 2013-10-17 Netapp, Inc. Systems and Methods for Selecting Data Compression for Storage Data in a Storage System
CN105025166A (en) * 2015-07-09 2015-11-04 深圳市金立通信设备有限公司 File processing method and terminal
CN109683913A (en) * 2018-11-14 2019-04-26 深圳壹账通智能科技有限公司 Generate method and device, the computer equipment, storage medium of compressed package

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
ATE311692T1 (en) * 1997-03-07 2005-12-15 Intelligent Compression Techno DATA ENCODING NETWORK
CN104850561A (en) * 2014-02-18 2015-08-19 北京京东尚科信息技术有限公司 Adaptive compression method for Android APK file
CN110286917A (en) * 2019-05-21 2019-09-27 深圳壹账通智能科技有限公司 File packing method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1139883C (en) * 2001-08-20 2004-02-25 北京九州计算机网络有限公司 Intelligent compression method for file of computer
US20110167173A1 (en) * 2010-01-05 2011-07-07 International Business Machines Corporation Optimal Compression Process Selection Methods
US20130275396A1 (en) * 2012-04-11 2013-10-17 Netapp, Inc. Systems and Methods for Selecting Data Compression for Storage Data in a Storage System
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
CN105025166A (en) * 2015-07-09 2015-11-04 深圳市金立通信设备有限公司 File processing method and terminal
CN109683913A (en) * 2018-11-14 2019-04-26 深圳壹账通智能科技有限公司 Generate method and device, the computer equipment, storage medium of compressed package

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020233057A1 (en) * 2019-05-21 2020-11-26 深圳壹账通智能科技有限公司 File packaging method, apparatus and device, and storage medium
CN111046311A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Method and device for realizing traceless iteration version of PC (personal computer) end, computer equipment and storage medium
CN111045654A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Vue-based method and device for quickly generating common instructions, computer equipment and storage medium
CN111176628A (en) * 2019-12-19 2020-05-19 福建天泉教育科技有限公司 Front-end access method under modular architecture and storage medium
CN111176628B (en) * 2019-12-19 2023-04-18 福建天泉教育科技有限公司 Front-end access method under modular architecture and storage medium
CN111240684A (en) * 2020-01-03 2020-06-05 北京字节跳动网络技术有限公司 Cutting method and device of JS code, medium and electronic equipment
CN111240684B (en) * 2020-01-03 2023-04-11 北京字节跳动网络技术有限公司 Cutting method and device of JS codes, medium and electronic equipment
CN111724133A (en) * 2020-06-19 2020-09-29 北京达佳互联信息技术有限公司 Method and device for creating project
CN111966639A (en) * 2020-08-27 2020-11-20 恒为科技(上海)股份有限公司 Generating and processing method and device for PCB production file

Also Published As

Publication number Publication date
WO2020233057A1 (en) 2020-11-26

Similar Documents

Publication Publication Date Title
CN110286917A (en) File packing method, device, equipment and storage medium
US10901709B2 (en) Partitioning based migration of systems to container and microservice based platforms
US8413044B2 (en) Method and system of retrieving Ajax web page content
CN104899016B (en) Allocating stack Relation acquisition method and device
CN107577509A (en) A kind of method, terminal and computer-readable recording medium for loading application interface
CN105205144B (en) Method and system for data diagnosis optimization
CN102945347A (en) Method, system and device for detecting Android malicious software
CN105095367B (en) A kind of acquisition method and device of client data
CN109672580A (en) Full link monitoring method, apparatus, terminal device and storage medium
CN109902274A (en) A kind of method and system converting json character string to thrift binary stream
CN109558128A (en) Json data analysis method, device and computer readable storage medium
TW201520897A (en) Hybrid dynamic code compiling device, method, and service system thereof
CN113703785B (en) Component-based platform deployment method, device, equipment and storage medium
CN108664471A (en) Text region error correction method, device, equipment and computer readable storage medium
JP2004341671A (en) Information processing system, control method, control program and recording medium
CN111866158B (en) Routing method, routing device, computer equipment and storage medium
CN107797823A (en) Business Rule Management method, apparatus, storage medium and computer equipment
CN113268245A (en) Code analysis method, device and storage medium
CN112417338A (en) Page adaptation method, system and equipment
CN107818107A (en) The method and apparatus for controlling page jump
KR20120122959A (en) Method and Device for Collecting Web Contents and Computer-readable Recording Medium for the same
CN109559121A (en) Transaction path calls exception analysis method, device, equipment and readable storage medium storing program for executing
CN105468412A (en) Dynamic packaging method and dynamic packaging device
CN110826074A (en) Application vulnerability detection method and device and computer readable storage medium
CN114489681B (en) Mobile terminal cross-platform development system and method based on browser kernel

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination