简体   繁体   English

如何防止 grunt uglify 覆盖目标文件夹

[英]How to prevent grunt uglify to override destination folder

I am trying to setup my grunt file to not to override some folders inside the destination folders, but I couldn't figure out how.我试图将我的 grunt 文件设置为不覆盖目标文件夹中的某些文件夹,但我不知道如何。

My structure我的结构

Basically I have 2 folders:基本上我有2个文件夹:

  • htdocs文档
  • htdocs_src htdocs_src 在此处输入图片说明

htdocs_src is the folder we use to develop things, and then we run a watch task that copies all the code to htdocs folder. htdocs_src 是我们用来开发东西的文件夹,然后我们运行一个 watch 任务,将所有代码复制到 htdocs 文件夹中。

My problem我的问题

We add some libraries directly on the htdocs folder, so we don't want them to be touched by grunt uglify task... The problem is that it is not happening.我们直接在 htdocs 文件夹中添加了一些库,所以我们不希望它们被 grunt uglify 任务触及......问题是它没有发生。

The task is configured this way:任务是这样配置的:

uglify: {
        options : {
            beautify: false,
            report: "min",
            mangle: {
                except: ['jQuery']
            },
            exclude: ['!/ifc-easy-checkout*/**/*', '!/ifc-events*/**/*', '!/ifc-vendors*/**/*'],
            compress: {
                global_defs: {
                  "DEBUG": false
                }/*,
                dead_code: true*/
            }
        },
        target: {
            cwd: '<%= dirs.GENERATED_JS %>',
            src: ['**/*.js'],
            dest: '<%= dirs.GENERATED_JS %>',
            expand: true
        },
    },

where on the exclude property I try to say to the plugin not to override these folders, but it doesn't work.我试图告诉插件不要覆盖这些文件夹,但它不起作用。

I am currently using grunt-contrib-uglify 2.0.0我目前正在使用 grunt-contrib-uglify 2.0.0

I tried several different solutions, such as changing the exclude property for exceptionsFiles, but then it searched for these folders inside the htdocs_src, since it is not there, it doesn't work (but it isn't what I want, once what I need is to avoid some folders to be overriden inside the destination folder).我尝试了几种不同的解决方案,例如更改 exceptionsFiles 的 exclude 属性,但随后它在 htdocs_src 中搜索这些文件夹,因为它不存在,因此不起作用(但它不是我想要的,一旦我需要的是避免在目标文件夹内覆盖某些文件夹)。

Any ideas how to setup this plugin?任何想法如何设置这个插件?

Try putting the excluded files in the src and remove the exclude tag尝试将排除的文件放在 src 中并删除exclude标记

 target: {
            cwd: '<%= dirs.GENERATED_JS %>',
            src: ['**/*.js','!/ifc-easy-checkout*/**/*', '!/ifc-events*/**/*', '!/ifc-vendors*/**/*'],
            dest: '<%= dirs.GENERATED_JS %>',
            expand: true
        },

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

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