PhpStorm:如何仅在 1 个 JS 文件上而不是在所有 JS 文件上添加观察者? [英] PhpStorm: how to add watcher on 1 JS file only and not on ALL JS files?

查看:62
本文介绍了PhpStorm:如何仅在 1 个 JS 文件上而不是在所有 JS 文件上添加观察者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1) 如何仅在 1 个文件上添加观察者?

1) How to add a watcher on 1 file ONLY ?

目标是仅在 1 个 JS 文件(main.js)上放置混淆器:我无法做到:混淆应用于我修改的任何 JS 文件.

The goal is to put a obfuscator on 1 JS file only (the main.js) : I was unable to do that: obfuscation is applied to ANY JS file I do modify.

2) 如何避免无限循环规则?我现在有 2 个观察者:

2) How to avoid infinite recurrent rules ? I have 2 watchers right now:

  • 缩小 JS 文件
  • 混淆 JS 文件

问题是:PhpStorm 创建了无限的 .min.obf.min.obf...js :它看起来无限地应用了这两个规则.

Problem is: PhpStorm creates infinite .min.obf.min.obf...js : it looks it applies these 2 rules in endless.

推荐答案

使用 Scope 字段来限制观看的文件:create 自定义范围 将仅包含所需的文件和/或文件夹,并在文件观察器中使用它.

Use Scope field to limit the watched files: create custom Scope that will include only desired file(s) and/or folders and use it there in File Watcher.

Scope 可以同时接受包含"和排除"模式,因此在过滤文件时非常灵活.

Scope can accept both "include" and "exclude" patterns at the same time so it's very flexible in filtering the files.

第二个问题的相同方法 - 使用范围不处理已处理的文件.

The same approach for your second issue -- use scope to not to process already processed files.

例如:https://stackoverflow.com/a/24938053/783119

拥有 2 个独立文件观察器的替代方法是创建一些批处理/shell 脚本,该脚本将执行缩小 + 混淆并将其用作文件观察器中的程序.

The alternative to having 2 separate File Watchers is creating some batch/shell script that will do that minification + obfuscation and use it as a program in File Watcher.

另一种选择——使用构建工具(Grunt/Gulp 或类似工具)并在那里调用适当的任务.

Another option -- use build tools (Grunt/Gulp or alike) and call appropriate task there.

这篇关于PhpStorm:如何仅在 1 个 JS 文件上而不是在所有 JS 文件上添加观察者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆