WO2020233057A1 - 文件打包方法、装置、设备及存储介质 - Google Patents

文件打包方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2020233057A1
WO2020233057A1 PCT/CN2019/120921 CN2019120921W WO2020233057A1 WO 2020233057 A1 WO2020233057 A1 WO 2020233057A1 CN 2019120921 W CN2019120921 W CN 2019120921W WO 2020233057 A1 WO2020233057 A1 WO 2020233057A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
packaging
project
packaged
optimizable
Prior art date
Application number
PCT/CN2019/120921
Other languages
English (en)
French (fr)
Inventor
王冬扬
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233057A1 publication Critical patent/WO2020233057A1/zh

Links

Classifications

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

Definitions

  • This application relates to the field of computer technology, in particular to a file packaging method, device, equipment and storage medium.
  • each functional module corresponding to the software application needs to be packaged and compressed.
  • the existing packaging method of application files usually uses webpack (a static module packager for applications) to package the application files that need to be packaged in general.
  • webpack a static module packager for applications
  • the main purpose of this application is to provide a file packaging method, device, equipment, and storage medium, which aims to solve the technical problems of low efficiency and long time-consuming when packaging application files in the prior art.
  • this application provides a file packaging method, which includes the following steps:
  • this application also proposes a file packaging device, which includes:
  • the packaging analysis module is configured to extract the file format identifier contained in the file packaging instruction when the file packaging instruction is received;
  • the packaging analysis module is further configured to search for a project file containing the file format identifier according to the file format identifier, and use the found project file as a project file to be packaged;
  • the package analysis module is also used to obtain the project file to be packaged, and perform package analysis on the project file to be packaged to obtain an analysis result;
  • the file judgment module is used to judge whether there is an optimizable project file in the project file to be packaged according to the analysis result
  • the file packaging module is used to obtain the target file type corresponding to the optimizable project file when the optimizable project file exists, and search for the target file type in the mapping relationship between the pre-built file type and the packaging optimization tool The corresponding packaging optimization tool;
  • the file packaging module is also used to package the optimizable project file through the found packaging optimization tool to obtain a packaging file;
  • the file merging module is used to package and compress the remaining project files in the project file to be packaged, and merge the obtained packaged compressed file with the packaged file to obtain the target packaged file.
  • this application also proposes a file packaging device, the device includes: a memory, a processor, and computer readable instructions stored on the memory and executable by the processor, wherein the When the computer-readable instructions are executed by the processor, the steps of the file packaging method described above are realized.
  • this application also proposes a storage medium having computer-readable instructions stored thereon, and when the computer-readable instructions are executed by a processor, the steps of the file packaging method described above are implemented .
  • FIG. 1 is a schematic structural diagram of a file packaging device of a hardware operating environment involved in a solution of an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for packaging application documents
  • FIG. 3 is a schematic flowchart of a second embodiment of a method for packaging application documents
  • FIG. 4 is a schematic flowchart of a third embodiment of a method for packaging application documents
  • Fig. 5 is a structural block diagram of the first embodiment of the file packaging device of this application.
  • FIG. 1 is a schematic structural diagram of a file packaging device of a hardware operating environment involved in a solution of an embodiment of the application.
  • the file packaging device may include a processor 1001, such as a central processing unit (Central Processing Unit). Unit, CPU), communication bus 1002, user interface 1003, network interface 1004, memory 1005.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface).
  • WIreless-FIdelity WI-FI
  • the memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, can also be a stable non-volatile memory (Non-Volatile Memory, NVM), such as disk storage.
  • RAM Random Access Memory
  • NVM Non-Volatile Memory
  • the memory 1005 may also be a storage device independent of the foregoing processor 1001.
  • FIG. 1 does not constitute a limitation on the file packaging device, and may include more or less components than those shown in the figure, or combine certain components, or different component arrangements.
  • the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and computer readable instructions.
  • the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with users; the processor 1001 and the memory 1005 in the file packaging device of this application can be Set in a file packaging device, the file packaging device calls computer-readable instructions stored in the memory 1005 through the processor 1001, and executes the file packaging method provided in the embodiment of the present application.
  • FIG. 2 is a schematic flowchart of the first embodiment of the file packaging method of this application.
  • the file packaging method includes the following steps:
  • Step S10 when receiving the file packaging instruction, extract the file format identifier contained in the file packaging instruction;
  • the execution subject of the method in this embodiment may be a computing service device or terminal with data processing, network communication, and program running functions, such as a tablet computer, a personal computer, etc. (hereinafter referred to as a package terminal).
  • the project file to be packaged may be an application code file that needs to be packaged and compressed. This embodiment is applied to a webpack-based code file packaging scenario, and mainly aims at optimizing the packaging process for the existing webpack packaging technology.
  • the webpack is a static module packer for modern JavaScript applications (module bundler).
  • module bundler When webpack processes the application, it recursively builds a dependency graph (dependency graph), which contains each module needed by the application, and then package all these modules into one or more bundles.
  • the file packaging instruction may be a request command carrying a file format identifier corresponding to the project file to be packaged.
  • the file format identifier may be character information that can be used to characterize the type or type of data exchange format.
  • Commonly used data exchange formats are JSON (JavaScript Object Notation), XML (eXtensible Markup Language), YAML (Yet Another Markup Language), etc.
  • the file format identifier in this embodiment may be the English abbreviation of the above-mentioned data exchange formats such as JSON, XML, and YAML.
  • the user can input the file packaging instruction "webpack --profile --json" on the packaging terminal > stats.json", of course, the file packaging instructions can also be triggered by the preset timing tasks in the packaging terminal.
  • the packaging terminal receives the file packaging instruction "webpack --profile --json> stats.json", the file format identifier "json" contained in the instruction can be extracted, and then the file corresponding to this packaging operation can be obtained according to the file format identifier.
  • Step S20 Find the project file containing the file format identifier according to the file format identifier, and use the found project file as the project file to be packaged;
  • JavaScript is a scripting language belonging to the network, which has been widely used in web application development. It is often used to add various dynamic functions to web pages and provide users with smoother and beautiful browsing effects.
  • the packaging terminal extracts the file format identifier "json" contained in the file packaging instructions, and then can Search for the project file that contains the file format identifier in the application code file, that is, all json format files, and then use the found json file as the project file to be packaged this time.
  • Step S30 Obtain a project file to be packaged, and perform package analysis on the project file to be packaged to obtain an analysis result;
  • webpack will use different loaders for different resource types (or file types) during the packaging process, and then integrate all static resources into one bundle.
  • resource types or file types
  • the specific process of packaging is different, and the packaging process of some resource type code files can be optimized during the packaging process to improve the packaging efficiency. Therefore, in this embodiment, during the packaging process, the project file to be packaged can be packaged and analyzed first, and then the steps or project files that can be optimized for the packaging process are found according to the analysis result.
  • the packaging terminal may first obtain the project file to be packaged, and then perform packaging analysis on the project file to be packaged by a packaging analysis tool to obtain the analysis result.
  • Step S40 Determine whether there is an optimizable project file in the project file to be packaged according to the analysis result
  • the files packaged by the webpack+vue project are often hundreds of kilobytes (Kilobyte, Kb) or even megabytes.
  • the reason is: the packaging of cascading style sheets (Cascading Style Sheets, CSS) files, webpack will directly package them as a module into a literal scripting language (JavaScript, JS) file; all JS modules + dependencies (ie, related modules of JS modules) are packaged into one file ; The réelle file is too large.
  • these types of files can be optimized in the packaging process. Therefore, in this embodiment, combining the actual packaging situation, the above three types of files are used as the optimizable project files.
  • the optimizable project file in this embodiment is not limited to the above three types of files.
  • the packaging terminal uses the packaging analysis tool to package and analyze the packaged project files and obtain the analysis results, it can query whether the analysis results include optimizable project files, such as CSS files, JS modules + dependencies, and / Or réelle files, etc.
  • optimizable project files such as CSS files, JS modules + dependencies, and / Or réelle files, etc.
  • Step S50 If it exists, obtain the target file type corresponding to the optimizable project file, and search for the packaging optimization tool corresponding to the target file type in the mapping relationship between the pre-built file type and the packaging optimization tool;
  • the packaging optimization tool can be a packaging optimization tool or plug-in that the developer configures in advance for different optimizable project files.
  • the extract-text-webpack-plugin is used to package CSS files and execute new The webpack.optimize.CommonsChunkPlugin('common.js') function extracts common code for packaging, and switches the production version of the réelle file through the webpack.DefinePlugin plug-in to reduce the file size of the réelle file.
  • the packaging terminal when the packaging terminal determines that the above-mentioned optimizable project files exist in the project files to be packaged according to the obtained analysis results, it can find the corresponding packaging optimization tools according to these project files, and then according to the obtained package The optimization tool packs the files.
  • a mapping relationship between the file type and the corresponding packaging optimization tool can be established in the packaging terminal, so that when the packaging terminal determines the optimizable project file for this file packaging, it obtains the optimizable project file According to the above-mentioned mapping relationship, obtain and call the corresponding packaging optimization tool quickly and accurately.
  • the file type of the optimized project file and the corresponding packaging optimization tool in the above mapping relationship in this embodiment may be associated with key-value pairs.
  • key value
  • key can be a file type that can optimize project files (such as CSS files, JS modules + dependencies, réelle files, etc.)
  • value can be a pre-configured packaging optimization tool or plug-in (for example, extract -text-webpack-plugin, new webpack.optimize.CommonsChunkPlugin ('common.js') function and webpack.DefinePlugin plug-in etc.).
  • the packaging terminal may obtain the target file type corresponding to the optimizable project file, and search for the packaging optimization tool corresponding to the target file type in the mapping relationship between the pre-built file type and the packaging optimization tool;
  • the obtained packaging optimization tool packs the optimizable project file to obtain the packaging file.
  • the packaging terminal in this embodiment will also count the number of types corresponding to the target file type (for example, the target file type includes CSS files, réelle files).
  • File the number of types is 2), and it is detected whether the number of types exceeds the preset number; if it does not exceed, the single-threaded operating mechanism is used to execute the optimization of the optimizable project file through the found packaging optimization tool.
  • the step of packaging to obtain the packaged file; if it exceeds, the pre-configured multi-threaded plug-in "webpack-parallel-uglify-plugin" is called to execute the step S60 in parallel.
  • Step S60 package the optimizable project file through the found packaging optimization tool to obtain a package file
  • the packaging terminal of this embodiment can divide each project file to be packaged into an optimizable project file and a non-optimized project file, and then package the optimizable project file according to the pre-configured packaging optimization tool.
  • the non-optimizable project file refers to the remaining project files in the project file to be packaged except for the optimizable project file.
  • the non-optimized project file described in this embodiment is not always non-optimized.
  • the developer can also perform package optimization analysis and analysis for some files in the non-optimized project file according to the actual situation. Configure the corresponding packaging tools, and then use these files as new optimizable project files.
  • Step S70 Pack and compress the remaining project files in the to-be-packed project file, and merge the obtained packed compressed file with the packed file to obtain a target packed file.
  • the packaging terminal may package and compress the remaining project files in the project file to be packaged, and merge the obtained packaged compressed file with the packaged file to obtain the final packaged target packaged file.
  • the file is packaged and analyzed first, and then it is determined whether there is a project file that can be optimized according to the analysis result. If there is, the optimizable project file is optimized and packaged according to the pre-configured packaging optimization tool, so that it can be targeted Packing optimizable project files, even if a single optimizable project file fails to package, it will not affect the packaging of other files, thereby shortening the packaging time and improving packaging efficiency.
  • FIG. 3 is a schematic flowchart of a second embodiment of a file packaging method of this application.
  • the step S30 may include:
  • Step S301 Obtain a project file to be packaged, and detect whether the file size corresponding to the project file to be packaged exceeds a preset file size;
  • the file packaging method in the first embodiment can indeed reduce packaging time and improve packaging efficiency for applications with larger file volumes;
  • the analysis in the first embodiment is still used to find optimizable project files, the method of separately performing packaging operations according to the packaging optimization tool configured by the developer will increase the development cost and increase the developer's workload.
  • the packaging terminal of this embodiment first obtains the file size of the project file to be packaged when acquiring the project file to be packaged, and then detects whether the file size exceeds the preset file size (the specific value is not limited ), and then perform corresponding follow-up operations based on the test results.
  • the preset file size the specific value is not limited
  • Step S302 If it exceeds, call a preset file packaging analysis tool to perform packaging analysis on the project file to be packaged to obtain an analysis result.
  • the preset file packaging tool may be a website with webpack file analysis function, such as “webpack/analyse”, “Webpack Chart” etc.
  • the packaging terminal detects that the file size corresponding to the project file to be packaged exceeds the preset file size, it indicates that the file size is too large. If a general direct packaging compression method is used, the packaging efficiency will be low. Then, the preset file packaging analysis tool can be called to perform packaging analysis on the project file to be packaged to obtain the analysis result.
  • the packaging terminal detects that the file size corresponding to the project file to be packaged does not exceed the preset file size, it indicates that the file size is not very large, and the direct packaging compression method is more efficient. At this time, the packaging terminal can treat the packaged project The file is directly packaged and compressed to obtain the compressed file.
  • this embodiment determines which packaging operation to perform according to the file size of the file to be packaged, compared to the existing method of directly packaging all files, the packaging operation can be performed more practically and effectively, and the packaging efficiency is improved.
  • FIG. 4 is a schematic flowchart of a third embodiment of a file packaging method of this application.
  • the optimizable project file includes a cascading style sheet file; correspondingly, the optimizable project file is packaged by the found packaging optimization tool to obtain a package file Steps can include:
  • Step S601 Obtain the current file size corresponding to the cascading style sheet file, and detect whether the current file size exceeds a preset threshold;
  • the packaging terminal when the packaging terminal detects that the optimizable project file includes a CSS file, it obtains the current file size corresponding to the CSS file, and detects whether the current file size exceeds the preset threshold.
  • Step S602 When the current file size exceeds the preset threshold, call a preset file packaging plugin to package the cascading style sheet file to obtain a packaged file.
  • the packaging terminal detects that the current file size exceeds the preset threshold, the preset file packaging plug-in "extract-text-webpack-plugin" is called to package the CSS file to obtain the packaged file.
  • the optimizable project file in this embodiment may also include a réelle file; accordingly, the step of packaging the optimizable project file through the found packaging optimization tool to obtain the packaged file may include:
  • the ceremonies file in this embodiment may be a file created by réelle.js (a set of progressive framework for building a user interface).
  • this embodiment adopts different processing methods for réelle files of different file sizes.
  • the packaging terminal may first obtain the target file size corresponding to the réelle file contained in the optimizable project file, and then detect whether the target file size exceeds a preset value; if it does not exceed the preset value, the réelle file is sent directly to The content distribution network where the corresponding application backend server is located (Content Delivery Network, CDN) for caching.
  • CDN Content Delivery Network
  • the packaging terminal detects that the réelle file is too large, it can perform version detection on it to determine whether the currently acquired réelle file belongs to the development version.
  • the packaging terminal when the packaging terminal detects that the current file version of the réelle file belongs to the development version, it can convert the version of the réelle file by calling the preset version conversion plug-in "webpack.DefinePlugin", and convert the version The latter file is used as a packaged file, thereby reducing the file size and speeding up the packaging efficiency.
  • the CSS file and the réelle file that are often included in the project file to be packaged are respectively optimized for the packaging process, which improves the packaging rate of these files in the packaging process and effectively shortens the packaging time.
  • the embodiments of the present application also provide a computer-readable storage medium, and the computer-readable storage medium may be a non-volatile readable storage medium.
  • the computer-readable storage medium of the present application stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the file packaging method as described above are realized.
  • FIG. 5 is a structural block diagram of the first embodiment of the file packaging device of this application.
  • the file packaging device proposed in the embodiment of the present application includes:
  • the packaging analysis module 501 is configured to extract the file format identifier contained in the file packaging instruction when the file packaging instruction is received;
  • the packaging analysis module 501 is further configured to search for a project file containing the file format identifier according to the file format identifier, and use the found project file as a project file to be packaged;
  • the packaging analysis module 501 is further configured to obtain the project file to be packaged, and perform packaging analysis on the project file to be packaged to obtain an analysis result;
  • the file judgment module 502 is configured to judge whether there is an optimizable project file in the project file to be packaged according to the analysis result;
  • the file packaging module 503 is configured to obtain the target file type corresponding to the optimizable project file when the optimizable project file exists, and search for the target file in the mapping relationship between the pre-built file type and the packaging optimization tool Packaging optimization tool corresponding to the type;
  • the file packaging module 503 is further configured to package the optimizable project file through the found packaging optimization tool to obtain a packaging file;
  • the file merging module 504 is configured to package and compress the remaining project files in the project file to be packaged, and merge the obtained packaged compressed file with the packaged file to obtain a target packaged file.
  • the files are packaged and analyzed first, and then based on the analysis results, it is determined whether there is a project file that can be optimized. If there is, the optimizable project file is optimized and packaged according to the pre-configured packaging optimization tool, so that the files can be targeted. Optimize project files for packaging, even if a single optimizable project file fails to package, it will not affect the packaging of other files, thereby shortening the packaging time and improving packaging efficiency.
  • the packaging analysis module 501 is also used to obtain the project file to be packaged, and detect whether the file size corresponding to the project file to be packaged exceeds the preset file size; if it exceeds, call the preset file packaging analysis The tool performs package analysis on the project file to be packaged to obtain analysis results.
  • the file packaging module 503 is also used to count the number of types corresponding to the target file type, and detect whether the number of types exceeds a preset number; if it does not exceed, a single-threaded operation mechanism is used to perform the search
  • the obtained packaging optimization tool packs the optimizable project file and obtains the operation of the packaging file.
  • the file packaging module 503 is further configured to, when it is detected that the number of types exceeds the preset number, call a pre-configured multi-threaded plug-in to execute the package optimization tool found through the search in parallel. Optimize project files for packaging and obtain the operation of packaging files.
  • the file packaging module 503 is also used to obtain the current file size corresponding to the cascading style sheet file, and detect whether the current file size exceeds a preset threshold; when the current file size exceeds the preset When the threshold is set, the preset file packaging plug-in is called to package the cascading style sheet file to obtain the packaged file.
  • the file packaging module 503 is also used to obtain the target file size corresponding to the réelle file, and detect whether the target file size exceeds a preset value; when the target file size exceeds the preset value , Obtain the current file version of the réelle file, and detect whether the current file version belongs to the development version; if so, call the preset version conversion plug-in to perform version conversion on the réelle file, and use the converted file as Pack files.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种文件打包方法、装置、设备及存储介质,该方法包括:对待打包项目文件进行打包分析,判断待打包项目文件中是否存在可优化项目文件;若存在则获取对应的打包优化工具,并根据打包优化工具对可优化项目文件进行打包获得打包文件;对剩余的项目文件进行打包压缩,并将获得的打包压缩文件与打包文件进行合并,获取目标打包文件。由于是先进行打包分析,然后根据分析结果确定是否存在可优化的项目文件,若存在则根据打包优化工具对可优化项目文件进行优化打包,进而能够有针对性的对可优化项目文件进行打包,即使出现单个可优化项目文件打包失败也不影响其他文件的打包压缩,从而缩短了文件打包时长,提高了打包效率。

Description

文件打包方法、装置、设备及存储介质
本申请要求于2019年5月21日提交中国专利局、申请号为201910433071.3、发明名称为“文件打包方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中
技术领域
本申请涉及计算机技术领域,尤其涉及一种文件打包方法、装置、设备及存储介质。
背景技术
随着计算机软件技术的快速发展,各种类型的软件应用已成为大众生活不可或缺的一部分。在某些场景下,软件应用程序对应的各功能模块需要进行打包压缩。现有的应用文件的打包方法在对软件应用程序进行打包压缩时,通常都是采用webpack(一种应用程序静态模块打包器)工具对需要打包的应用程序文件笼统的进行打包,当需要打包的文件体积较大时,打包效率就会大打折扣,导致耗时较长,一旦出现报错的情况,就需要重新进行二次打包,缺点明显。
发明内容
本申请的主要目的在于提供了一种文件打包方法、装置、设备及存储介质,旨在解决现有技术在进行应用程序文件打包时,效率低、耗时长的技术问题。
为实现上述目的,本申请提供了一种文件打包方法,所述方法包括以下步骤:
在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
若存在,则获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
此外,为实现上述目的,本申请还提出一种文件打包装置,所述装置包括:
打包分析模块,用于在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
所述打包分析模块,还用于根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
所述打包分析模块,还用于获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
文件判断模块,用于根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
文件打包模块,用于存在所述可优化项目文件时,获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
所述文件打包模块,还用于通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
文件合并模块,用于对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
此外,为实现上述目的,本申请还提出一种文件打包设备,所述设备包括:存储器、处理器及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现如上文所述的文件打包方法的步骤。
此外,为实现上述目的,本申请还提出一种存储介质,所述存储介质上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现如上文所述的文件打包方法的步骤。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其他特征和优点将从说明书、附图以及权利要求书变得明显。
附图说明
图1是本申请实施例方案涉及的硬件运行环境的文件打包设备的结构示意图;
图2为本申请文件打包方法第一实施例的流程示意图;
图3为本申请文件打包方法第二实施例的流程示意图;
图4为本申请文件打包方法第三实施例的流程示意图;
图5为本申请文件打包装置第一实施例的结构框图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
参照图1,图1为本申请实施例方案涉及的硬件运行环境的文件打包设备结构示意图。
如图1所示,该文件打包设备可以包括:处理器1001,例如中央处理器(Central Processing Unit,CPU),通信总线1002、用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如无线保真(WIreless-FIdelity,WI-FI)接口)。存储器1005可以是高速的随机存取存储器(Random Access Memory,RAM)存储器,也可以是稳定的非易失性存储器(Non-Volatile Memory,NVM),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的结构并不构成对文件打包设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种存储介质的存储器1005中可以包括操作系统、数据存储模块、网络通信模块、用户接口模块以及计算机可读指令。
在图1所示的文件打包设备中,网络接口1004主要用于与网络服务器进行数据通信;用户接口1003主要用于与用户进行数据交互;本申请文件打包设备中的处理器1001、存储器1005可以设置在文件打包设备中,所述文件打包设备通过处理器1001调用存储器1005中存储的计算机可读指令,并执行本申请实施例提供的文件打包方法。
本申请实施例提供了一种文件打包方法,参照图2,图2为本申请文件打包方法第一实施例的流程示意图。
本实施例中,所述文件打包方法包括以下步骤:
步骤S10:在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
需要说明的是,本实施例方法的执行主体可以是具有数据处理、网络通信以及程序运行功能的计算服务设备或终端,例如平板电脑、个人电脑等(以下简称打包终端)。所述待打包项目文件可以是需要进行打包压缩的应用程序代码文件。本实施例应用于基于webpack的代码文件打包场景,主要是针对现有的webpack打包技术进行打包过程的优化。
应理解的是,所述webpack 是一个现代JavaScript应用程序的静态模块打包器(module bundler)。当webpack处理应用程序时,它会递归地构建一个依赖关系图(dependency graph),其中包含应用程序需要的每个模块,然后将所有这些模块打包成一个或多个bundle。
需要说明的是,所述文件打包指令可以是携带待打包项目文件对应的文件格式标识的请求命令。其中,所述文件格式标识可以是能够用来表征数据交换格式的种类或类型的字符信息,常用的数据交换格式有JSON(JavaScript Object Notation)、XML(eXtensible Markup Language)、YAML(Yet Another Markup Language)等,本实施例中所述文件格式标识可以是JSON、XML、YAML等上述数据交换格式的英文缩写。
此外,本实施例中用户可在打包终端上输入文件打包指令“webpack --profile --json > stats.json”,当然该文件打包指令也可以由打包终端中预设的定时任务触发生成。
在具体实现中,打包终端在接收到文件打包指令“webpack --profile --json > stats.json”时,可提取该指令中包含的文件格式标识“json”,然后根据该文件格式标识获取本次打包操作对应的文件。
步骤S20:根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
应理解的是,JavaScript是一种属于网络的脚本语言,已经被广泛用于Web应用开发,常用来为网页添加各式各样的动态功能,为用户提供更流畅美观的浏览效果。考虑到某些特定场景下,需要对应用程序代码文件中包含的js文件进行分离,本实施例中打包终端在提取到文件打包指令中包含的文件格式标识“json”后,即可在待打包的应用程序代码文件中查找包含有该文件格式标识的项目文件,即所有json格式的文件,然后将查找到的json文件作为本次待打包的项目文件。
步骤S30:获取待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
可以理解的是,通常情况下,webpack在打包过程中会针对不同的资源类型(或文件类型)使用不同的loader处理,然后将所有静态资源整合到一个bundle里。对于一个应用程序而言由于代码文件模块功能或资源类型的不同,打包时的具体流程也不相同,某些资源类型的代码文件在打包过程中是可以进行打包过程优化以提高打包效率的。因此,本实施例在打包过程中可先对待打包的项目文件进行打包分析,然后根据分析结果找出可以进行打包过程优化的步骤或项目文件。
在具体实现中,打包终端可先获取待打包的项目文件,然后通过打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
步骤S40:根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
应理解的是,在实际打包过程中,webpack+vue的项目打包出来的文件经常动辄几百千字节(Kilobyte,Kb)甚至上兆,究其原因有:打包层叠样式表(Cascading Style Sheets,CSS)文件时,webpack会直接将其作为模块一并打包到直译式脚本语言(JavaScript,JS)文件中;将所有的JS模块+依赖(即JS模块的关联模块)都打包到一个文件;vue文件过大。而实际上这些类型的文件都是可以进行打包过程优化的,因此本实施例结合实际打包情况,将上述三种类型的文件作为所述可优化项目文件。当然,本实施例中所述可优化项目文件并不局限与上述三类文件。
在具体实现中,打包终端通过打包分析工具对待打包项目文件进行打包分析并获取分析结果后,即可查询所述分析结果中上否包含可优化的项目文件,例如CSS文件、JS模块+依赖和/或vue文件等。
步骤S50:若存在,则获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
需要说明的是,所述打包优化工具可以是开发人员预先针对不同的可优化项目文件配置的打包优化工具或插件,例如通过extract-text-webpack-plugin插件来对CSS文件进行打包、执行new webpack.optimize.CommonsChunkPlugin('common.js')函数来提取公共代码进行打包、通过webpack.DefinePlugin插件来切换vue文件的生产版本,以降低vue文件的文件体积等。
在具体实现中,打包终端在根据获取到的分析结果确定出待打包项目文件中存在上述可优化项目文件时,即可根据这些项目文件去查找对应的打包优化工具,然后根据获取到的这些打包优化工具对文件进行打包。
进一步地,考虑到不同的应用程序集成的代码文件以及代码文件的资源类型都不尽相同,但相同资源类型的文件对应的打包过程都大同小异,优化工具也几乎一样,为提高文件打包效率,本实施例中可在打包终端中建立一个文件类型和对应的打包优化工具之间的映射关系,以使得打包终端在确定出本次文件打包所针对的可优化项目文件时,通过获取可优化项目文件的文件类型,然后根据上述映射关系来快速准确地获取并调用对应的打包优化工具。
需要说明的是,为了便于对映射关系进行后续的动态修改或更新,本实施例上述映射关系中可优化项目文件的文件类型和对应的打包优化工具的关联方式可以通过键值对的方式来实现,例如“key =value”,其中“key”可以是可优化项目文件的文件类型(例如CSS文件、JS模块+依赖、vue文件等),“value”则可以是预先配置的打包优化工具或插件(例如,extract-text-webpack-plugin插件、new webpack.optimize.CommonsChunkPlugin('common.js')函数以及webpack.DefinePlugin插件等)。
具体的,打包终端可获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;然后根据查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件。
此外,为进一步提高打包效率,本实施例中打包终端在获取到可优化项目文件对应的目标文件类型后,还将统计所述目标文件类型对应的类型数量(例如目标文件类型包括CSS文件、vue文件,则所述类型数量为2),检测所述类型数量是否超过预设数量;若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤;若超过,则调用预先配置的多线程插件“webpack-parallel-uglify-plugin”并行执行所述步骤S60。
步骤S60:通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
需要说明的是,本实施例打包终端可将每一个待打包项目文件都进行可优化项目文件与不可优化项目文件的划分,然后对可优化项目文件按照预先配置的打包优化工具进行打包,对不可优化项目文件进行正常的打包压缩,这两种打包方式可同时进行,从而进一步提高打包效率。
其中,所述不可优化项目文件,即待打包项目文件中除所述可优化项目文件之外剩余的项目文件。另外需要说明的是,本实施例中所述不可优化项目文件并非是一直不可优化的,在后续应用过程中开发人员也可以根据实际情况针对不可优化项目文件中的某些文件进行打包优化分析并配置相应的打包工具,然后将这些文件作为新的可优化项目文件。
步骤S70:对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
在具体实现中,打包终端可对待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与打包文件进行合并,获取最终打包好的目标打包文件。
本实施例由于是先对文件进行打包分析,然后根据分析结果确定是否存在可以优化的项目文件,若存在则根据预先配置的打包优化工具对可优化项目文件进行优化打包,进而能够有针对性的对可优化项目文件进行打包,即使单个的可优化项目文件打包失败也不影响其他文件的打包,从而缩短了打包时长,提高了打包效率。
参考图3,图3为本申请文件打包方法第二实施例的流程示意图。
基于上述第一实施例,在本实施例中,所述步骤S30,可包括:
步骤S301:获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;
应理解的是,考虑到不同应用程序的文件体积都不相同,对于文件体积较大的应用程序采用第一实施例中的文件打包方式的确能够减少打包时间,提高打包效率;但对于文件体积较小的应用程序,若仍然采用第一实施例中的分析查找可优化项目文件,根据开发人员配置的打包优化工具分别进行打包操作的方式就会存在开发成本增加,加重开发人员工作量的问题。
为克服上述问题,本实施例打包终端在获取到待打包的项目文件时,先获取所述待打包项目文件的文件大小,然后检测所述文件大小是否超过预设文件大小(具体数值不做限定),再根据检测结果执行相应的后续操作。
步骤S302:若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
需要说明的是,所述预设文件打包工具可以是具有webpack文件分析功能的网站,如“webpack/analyse”、“Webpack Chart”等。
具体的,若打包终端检测到待打包项目文件对应的文件大小超过所述预设文件大小,则表明文件体积过大,若采用一般的直接打包压缩的方式将会导致打包效率低下的问题,此时即可调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
若打包终端检测到待打包项目文件对应的文件大小不超过所述预设文件大小,则表明文件体积不是很大,采用直接打包压缩的方式反而效率更高,此时打包终端即可对待打包项目文件直接进行打包压缩,以获取压缩后的文件。
本实施例由于是根据待打包文件的文件大小来判定执行何种打包操作,相比于现有的直接打包所有文件的方式,能够更加实际、有效的进行打包操作,提高打包效率。
参考图4,图4为本申请文件打包方法第三实施例的流程示意图。
基于上述各实施例,在本实施例中,所述可优化项目文件包括层叠样式表文件;相应地,所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤,可包括:
步骤S601:获取所述层叠样式表文件对应的当前文件大小,并检测所述当前文件大小是否超过预设阈值;
需要说明的是,现有的webpack在打包CSS文件的时候,往往会将这些文件直接作为一个模块一并打包到js文件中,针对这类情况,若使用预设文件打包插件“extract-text-webpack-plugin”对CSS文件进行打包将会产生更长时间的编译,也没有模块热替换(Hot Module Replacement,HMR),还会增加额外的超文本传输协议(HyperText Transfer Protocol,HTTP)请求,因此本实施例考虑设置一个阈值(即所述预设阈值)来使得打包终端在检测到CSS文件的文件大小不是很大(即不超过所述预设阈值)时,不使用该文件打包插件。
在具体实现中,打包终端在检测到所述可优化项目文件中包括CSS文件时,获取所述CSS文件对应的当前文件大小,并检测所述当前文件大小是否超过所述预设阈值。
步骤S602:在所述当前文件大小超过所述预设阈值时,调用预设文件打包插件对所述层叠样式表文件进行打包,获得打包文件。
若打包终端检测到所述当前文件大小超过所述预设阈值,则调用预设文件打包插件“extract-text-webpack-plugin”对CSS文件进行打包,获得打包文件。
进一步地,本实施例中所述可优化项目文件还可包括vue文件;相应地,所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤,可包括:
步骤:获取所述vue文件对应的目标文件大小,并检测所述目标文件大小是否超过预设数值;
应理解的是,本实施例中所述vue文件可以是通过vue.js(一套构建用户界面的渐进式框架)创建的文件。同样地,考虑到每个应用程序包含的vue文件的文件大小都不相同,为尽可能的提高打包效率,本实施例对不同文件大小的vue文件采用不同的处理方式。
在本步骤中,打包终端可先获取可优化项目文件中包含的vue文件对应的目标文件大小,然后检测所述目标文件大小是否超过预设数值;若不超过则将所述vue文件直接发送到对应的应用程序后台服务器所在的内容分发网络(Content Delivery Network,CDN)中进行缓存。
步骤:在所述目标文件大小超过所述预设数值时,获取所述vue文件的当前文件版本,并检测所述当前文件版本是否属于开发版本;
应理解的是,通常情况下,开发人员在开发环境下使用的开发版本的vue文件中包含很多代码注释或警告信息等,但实际部署到线上的生产版本则不需要上述代码注释和警告信息。因此,本实施例中打包终端在检测到vue文件过大时,可对其进行版本检测,以确定当前获取到的vue文件是否是属于开发版本。
步骤:若属于,则调用预设版本转换插件对所述vue文件进行版本转换,并将版本转换后的文件作为打包文件。
在本步骤中,打包终端在检测到所述vue文件的当前文件版本属于开发版本时,即可通过调用预设版本转换插件“webpack.DefinePlugin”对所述vue文件进行版本转换,并将版本转换后的文件作为打包文件,从而在减小文件体积的同时,加快打包效率。
本实施例对待打包项目文件中经常包含的CSS文件以及vue文件分别进行打包过程优化,提高了这些文件在打包过程中的打包速率,有效的缩短了打包时间。
此外,本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质可以为非易失性可读存储介质。
本申请计算机可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如上述的文件打包方法的步骤。
其中,该计算机可读指令被执行时所实现的方法可参照本申请文件打包方法的各个实施例,此处不再赘述。
参照图5,图5为本申请文件打包装置第一实施例的结构框图。
如图5所示,本申请实施例提出的文件打包装置包括:
打包分析模块501,用于在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
所述打包分析模块501,还用于根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
所述打包分析模块501,还用于获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
文件判断模块502,用于根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
文件打包模块503,用于存在所述可优化项目文件时,获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
所述文件打包模块503,还用于通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
文件合并模块504,用于对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
本实施例先对文件进行打包分析,然后根据分析结果确定是否存在可以优化的项目文件,若存在则根据预先配置的打包优化工具对可优化项目文件进行优化打包,进而能够有针对性的对可优化项目文件进行打包,即使单个的可优化项目文件打包失败也不影响其他文件的打包,从而缩短了打包时长,提高了打包效率。
基于本申请上述文件打包装置第一实施例,提出本申请文件打包装置的第二实施例。
在本实施例中,所述打包分析模块501,还用于获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
进一步地,所述文件打包模块503,还用于统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量;若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的操作。
进一步地,所述文件打包模块503,还用于在检测到所述类型数量超过所述预设数量时,调用预先配置的多线程插件并行执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的操作。
进一步地,所述文件打包模块503,还用于获取所述层叠样式表文件对应的当前文件大小,并检测所述当前文件大小是否超过预设阈值;在所述当前文件大小超过所述预设阈值时,调用预设文件打包插件对所述层叠样式表文件进行打包,获得打包文件。
进一步地,所述文件打包模块503,还用于获取所述vue文件对应的目标文件大小,并检测所述目标文件大小是否超过预设数值;在所述目标文件大小超过所述预设数值时,获取所述vue文件的当前文件版本,并检测所述当前文件版本是否属于开发版本;若属于,则调用预设版本转换插件对所述vue文件进行版本转换,并将版本转换后的文件作为打包文件。
本申请文件打包装置的其他实施例或具体实现方式可参照上述各方法实施例,此处不再赘述。

Claims (20)

  1. 一种文件打包方法,其中,所述方法包括:
    在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
    根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
    获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
    根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
    若存在,则获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
    通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
    对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
  2. 如权利要求1所述的方法,其中,所述获取待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果的步骤,包括:
    获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;
    若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
  3. 如权利要求1所述的方法,其中,所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤之前,所述方法还包括:
    统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量;
    若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
  4. 如权利要求3所述的方法,其中,所述统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量的步骤之后,所述方法还包括:
    若超过,则调用预先配置的多线程插件并行执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
  5. 如权利要求3所述的方法,其中,所述可优化项目文件包括层叠样式表文件;
    所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤,包括:
    获取所述层叠样式表文件对应的当前文件大小,并检测所述当前文件大小是否超过预设阈值;
    在所述当前文件大小超过所述预设阈值时,调用预设文件打包插件对所述层叠样式表文件进行打包,获得打包文件。
  6. 如权利要求5所述的方法,其中,所述可优化项目文件还包括vue文件;
    所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤,包括:
    获取所述vue文件对应的目标文件大小,并检测所述目标文件大小是否超过预设数值;
    在所述目标文件大小超过所述预设数值时,获取所述vue文件的当前文件版本,并检测所述当前文件版本是否属于开发版本;
    若属于,则调用预设版本转换插件对所述vue文件进行版本转换,并将版本转换后的文件作为打包文件。
  7. 一种文件打包装置,其中,所述装置包括:
    打包分析模块,用于在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
    所述打包分析模块,还用于根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
    所述打包分析模块,还用于获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
    文件判断模块,用于根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
    文件打包模块,用于存在所述可优化项目文件时,获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
    所述文件打包模块,还用于通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
    文件合并模块,用于对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
  8. 如权利要求7所述的装置,其中,所述打包分析模块,还用于获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
  9. 如权利要求7所述的装置,其中,所述文件打包模块,还用于统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量;若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的操作。
  10. 如权利要求9所述的装置,其中,所述文件打包模块,还用于在检测到所述类型数量超过所述预设数量时,调用预先配置的多线程插件并行执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的操作。
  11. 如权利要求9所述的装置,其中,所述可优化项目文件包括层叠样式表文件;
    所述文件打包模块,还用于获取所述层叠样式表文件对应的当前文件大小,并检测所述当前文件大小是否超过预设阈值;在所述当前文件大小超过所述预设阈值时,调用预设文件打包插件对所述层叠样式表文件进行打包,获得打包文件。
  12. 如权利要求11所述的装置,其中,所述可优化项目文件还包括vue文件;
    所述文件打包模块,还用于获取所述vue文件对应的目标文件大小,并检测所述目标文件大小是否超过预设数值;在所述目标文件大小超过所述预设数值时,获取所述vue文件的当前文件版本,并检测所述当前文件版本是否属于开发版本;若属于,则调用预设版本转换插件对所述vue文件进行版本转换,并将版本转换后的文件作为打包文件。
  13. 一种文件打包设备,其中,所述设备包括:存储器、处理器及存储在所述存储器上并可被所述处理器执行的计算机可读指令,其中所述计算机可读指令被所述处理器执行时,实现如下步骤:
    在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
    根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
    获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
    根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
    若存在,则获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
    通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
    对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
  14. 如权利要求13所述的设备,其中,所述获取待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果的步骤,包括:
    获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;
    若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
  15. 如权利要求13所述的设备,其中,所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤之前,所述方法还包括:
    统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量;
    若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
  16. 如权利要求15所述的设备,其中,所述统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量的步骤之后,所述方法还包括:
    若超过,则调用预先配置的多线程插件并行执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
  17. 一种存储介质,其中,所述计算机可读存储介质上存储有计算机可读指令,其中所述计算机可读指令被处理器执行时,实现如下步骤;
    在接收到文件打包指令时,提取所述文件打包指令中包含的文件格式标识;
    根据所述文件格式标识查找包含有所述文件格式标识的项目文件,并将查找到的项目文件作为待打包项目文件;
    获取所述待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果;
    根据所述分析结果判断所述待打包项目文件中是否存在可优化项目文件;
    若存在,则获取所述可优化项目文件对应的目标文件类型,在预先构建的文件类型和打包优化工具之间的映射关系中查找所述目标文件类型对应的打包优化工具;
    通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件;
    对所述待打包项目文件中剩余的项目文件进行打包压缩,并将获得的打包压缩文件与所述打包文件进行合并,获取目标打包文件。
  18. 如权利要求17所述的存储介质,其中,所述获取待打包项目文件,对所述待打包项目文件进行打包分析以获取分析结果的步骤,包括:
    获取待打包项目文件,检测所述待打包项目文件对应的文件大小是否超过预设文件大小;
    若超过,则调用预设文件打包分析工具对所述待打包项目文件进行打包分析以获取分析结果。
  19. 如权利要求17所述的存储介质,其中,所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤之前,所述方法还包括:
    统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量;
    若不超过,则采用单线程运行机制执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
  20. 如权利要求19所述的存储介质,其中,所述统计所述目标文件类型对应的类型数量,检测所述类型数量是否超过预设数量的步骤之后,所述方法还包括:
    若超过,则调用预先配置的多线程插件并行执行所述通过查找到的打包优化工具对所述可优化项目文件进行打包,获得打包文件的步骤。
PCT/CN2019/120921 2019-05-21 2019-11-26 文件打包方法、装置、设备及存储介质 WO2020233057A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910433071.3A CN110286917A (zh) 2019-05-21 2019-05-21 文件打包方法、装置、设备及存储介质
CN201910433071.3 2019-05-21

Publications (1)

Publication Number Publication Date
WO2020233057A1 true WO2020233057A1 (zh) 2020-11-26

Family

ID=68002485

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/120921 WO2020233057A1 (zh) 2019-05-21 2019-11-26 文件打包方法、装置、设备及存储介质

Country Status (2)

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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356296A (zh) * 2021-12-30 2022-04-15 上海米哈游璃月科技有限公司 资源打包方法、装置、电子设备及存储介质
CN115774559A (zh) * 2022-11-30 2023-03-10 成都赛力斯科技有限公司 一种应用程序的管理方法、装置、电子设备及存储介质

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110286917A (zh) * 2019-05-21 2019-09-27 深圳壹账通智能科技有限公司 文件打包方法、装置、设备及存储介质
CN111045654A (zh) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 基于Vue快速生成常用指令的方法、装置、计算机设备及存储介质
CN111046311A (zh) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 实现pc端无痕迭代版本的方法、装置、计算机设备及存储介质
CN111176628B (zh) * 2019-12-19 2023-04-18 福建天泉教育科技有限公司 组件化架构下的前端接入方法、存储介质
CN111240684B (zh) * 2020-01-03 2023-04-11 北京字节跳动网络技术有限公司 一种js代码的裁剪方法、装置、介质和电子设备
CN111724133A (zh) * 2020-06-19 2020-09-29 北京达佳互联信息技术有限公司 一种创建项目的方法及装置
CN111966639A (zh) * 2020-08-27 2020-11-20 恒为科技(上海)股份有限公司 一种pcb生产文件的生成处理方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6253264B1 (en) * 1997-03-07 2001-06-26 Intelligent Compression Technologies Coding network grouping data of same data type into blocks using file data structure and selecting compression for individual block base on block data type
CN1139883C (zh) * 2001-08-20 2004-02-25 北京九州计算机网络有限公司 计算机文件的智能压缩和解压缩方法
CN102761540A (zh) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 数据压缩方法、装置、系统以及服务器
CN104850561A (zh) * 2014-02-18 2015-08-19 北京京东尚科信息技术有限公司 一种Android APK文件自适应压缩方法
CN110286917A (zh) * 2019-05-21 2019-09-27 深圳壹账通智能科技有限公司 文件打包方法、装置、设备及存储介质

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8463944B2 (en) * 2010-01-05 2013-06-11 International Business Machines Corporation Optimal compression process selection methods
US9048862B2 (en) * 2012-04-11 2015-06-02 Netapp, Inc. Systems and methods for selecting data compression for storage data in a storage system
CN105025166A (zh) * 2015-07-09 2015-11-04 深圳市金立通信设备有限公司 一种文件处理方法及终端
CN109683913A (zh) * 2018-11-14 2019-04-26 深圳壹账通智能科技有限公司 生成压缩包的方法及装置、计算机设备、存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6253264B1 (en) * 1997-03-07 2001-06-26 Intelligent Compression Technologies Coding network grouping data of same data type into blocks using file data structure and selecting compression for individual block base on block data type
CN1139883C (zh) * 2001-08-20 2004-02-25 北京九州计算机网络有限公司 计算机文件的智能压缩和解压缩方法
CN102761540A (zh) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 数据压缩方法、装置、系统以及服务器
CN104850561A (zh) * 2014-02-18 2015-08-19 北京京东尚科信息技术有限公司 一种Android APK文件自适应压缩方法
CN110286917A (zh) * 2019-05-21 2019-09-27 深圳壹账通智能科技有限公司 文件打包方法、装置、设备及存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356296A (zh) * 2021-12-30 2022-04-15 上海米哈游璃月科技有限公司 资源打包方法、装置、电子设备及存储介质
CN115774559A (zh) * 2022-11-30 2023-03-10 成都赛力斯科技有限公司 一种应用程序的管理方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN110286917A (zh) 2019-09-27

Similar Documents

Publication Publication Date Title
WO2020233057A1 (zh) 文件打包方法、装置、设备及存储介质
WO2020233077A1 (zh) 系统服务的监控方法、装置、设备及存储介质
WO2020015067A1 (zh) 数据采集方法、装置、设备及存储介质
WO2018036167A1 (zh) 测试任务执行机分配方法、装置、服务器和存储介质
WO2021072881A1 (zh) 基于对象存储的请求处理方法、装置、设备及存储介质
WO2020253135A1 (zh) 自动化分析方法、用户设备、存储介质及装置
WO2020077832A1 (zh) 云桌面的访问方法、装置、设备及存储介质
WO2018014580A1 (zh) 数据接口测试方法、装置、服务器和存储介质
WO2014101023A1 (zh) 一种防止业务非法访问的方法和装置
WO2020147385A1 (zh) 数据录入方法、装置、终端及计算机可读存储介质
WO2012060669A1 (ko) Sms를 통해 원격 디바이스를 제어하는 방법 및 이를 위한 장치
WO2020015060A1 (zh) 用电量异常评估方法、装置、设备和计算机存储介质
WO2012155709A1 (zh) 一种动态推送用户个人标签的方法和系统、存储介质
WO2020119115A1 (zh) 数据审核方法、装置、设备及存储介质
WO2019109957A1 (zh) 基于esb的服务提供方法、装置、设备及可读存储介质
WO2020233073A1 (zh) 区块链环境检测方法、设备、装置及存储介质
WO2021012489A1 (zh) 电话平台日志查询方法、终端设备、存储介质及装置
WO2020224251A1 (zh) 区块链事务的处理方法、装置、设备及存储介质
WO2020107591A1 (zh) 重复投保限制方法、装置、设备及可读存储介质
WO2012059005A1 (zh) 跨进程通信的方法和装置、计算机存储介质
WO2020098075A1 (zh) 金融数据处理方法、装置、设备和存储介质
WO2020233089A1 (zh) 测试用例生成方法、装置、终端及计算机可读存储介质
WO2020037909A1 (zh) 基于日志的资源调整方法、设备、存储介质及装置
WO2020186791A1 (zh) 数据传输方法、装置、设备及存储介质
WO2020119062A1 (zh) 预装应用管理方法、装置及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19929860

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 040322)

122 Ep: pct application non-entry in european phase

Ref document number: 19929860

Country of ref document: EP

Kind code of ref document: A1