简体   繁体   English

如何分别缩小文件

[英]How to minify files individually

I am trying to minify my files in a different directory but keep the same directory structure. 我正在尝试缩小其他目录中的文件,但保持相同的目录结构。 I am using ReactJS on separate pages individually. 我在单独的页面上分别使用ReactJS。 Here is my directory structure. 这是我的目录结构。

-- src/
     --admin/
          --admin.js
          --users.js
     --a.js
     --b.js

Here is how the bundle directory should be: 捆绑包目录应如下所示:

-- dist/
    --admin/
        --admin.min.js
        --users.min.js
    --a.min.js
    --b.min.js

As you can see the directory structure is copied to dist directory and all files are minified individually in their designated directory. 如您所见,目录结构已复制到dist目录,并且所有文件都在其指定目录中分别缩小。

You can use task runners for tasks like that such as Gulp. 您可以将任务运行器用于诸如Gulp之类的任务。 With this you can include packages where you automate minification into the folders you want. 使用此工具,您可以将软件包自动打包到所需的文件夹中。 To use Gulp you need to have Node.js installed. 要使用Gulp,您需要安装Node.js。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM