macos 你如何在 OS X 或 Webstorm 上自动缩小你的 JS 和 CSS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9169020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 08:50:17  来源:igfitidea点击:

How do you automagically minify your JS and CSS on OS X or in Webstorm?

javascriptidecssmacos

提问by Chase Florell

I use two different IDE's based on what I'm doing. My primary IDE is Visual Studio, whereby I use Chirpyto mash and minify my code. It works flawlessly and I love it. Problem is that when I'm not on my Windows box, I don't have access to it.

我根据我正在做的事情使用两种不同的 IDE。我的主要 IDE 是 Visual Studio,我使用Chirpy来混合和缩小我的代码。它完美无缺,我喜欢它。问题是当我不在我的 Windows 机器上时,我无法访问它。

When not using Visual Studio, I'm usually writing Javascript apps in Webstorm on my Macbook Pro. Here in lies the problem. I haven't found a Webstorm plugin or any other app that I can configure to watch my scripts and mash/minify them.

不使用 Visual Studio 时,我通常在 Macbook Pro 上的 Webstorm 中编写 Javascript 应用程序。问题就在这里。我还没有找到 Webstorm 插件或任何其他可以配置来观看我的脚本并混搭/缩小它们的应用程序。

How do you Mac users mash/minify your JS and CSS at design time with minimal effort?

您的 Mac 用户如何在设计时以最少的努力混搭/缩小您的 JS 和 CSS?

回答by Sam

For those who have now updated to WebStorm 6, this functionality is in-built. Simply go to File (or whatever the Mac equivalent is) -> Settings -> File Watchers and define a file watcher for the type of file you need to watch.

对于现在更新到 WebStorm 6 的用户,此功能是内置的。只需转到文件(或任何 Mac 等效项)-> 设置 -> 文件观察器并为您需要观察的文件类型定义文件观察器。

The relevant help documentation is here - http://www.jetbrains.com/webstorm/webhelp/using-file-watchers.html

相关帮助文档在这里 - http://www.jetbrains.com/webstorm/webhelp/using-file-watchers.html

回答by Jonathan Ong

I use lesscand uglifyjsto concatenate and minify my css and js files. Here's a makefile from Twitter Bootstrap that I used a modified version of:

我使用lesscuglifyjs来连接和缩小我的 css 和 js 文件。这是来自 Twitter Bootstrap 的生成文件,我使用了以下文件的修改版本:

https://github.com/twitter/bootstrap/blob/master/Makefile

https://github.com/twitter/bootstrap/blob/master/Makefile

It's simple since all I do is type makein the command line whenever I want to compile.

这很简单,因为make只要我想编译,我所做的就是在命令行中输入。

回答by Marius Nitsche

You could use YUI Compressor without Command Line with these little Apps:

您可以在没有命令行的情况下通过这些小应用程序使用 YUI Compressor:

回答by Sean

I'm neither a Mac nor Webstorm user, but this might still be relevant.

我既不是 Mac 也不是 Webstorm 用户,但这可能仍然相关。

For javascript I use the closure compileras part of an upload script to minify. It doesn't monitor the files, it runs when I run the upload (a bash file).

对于 javascript,我使用闭包编译器作为上传脚本的一部分来缩小。它不监视文件,它在我运行上传(一个 bash 文件)时运行。

If you wanted to keep it all in the IDE, it looks like Webstorm has an Ant plugin http://plugins.intellij.net/plugin/?webide&id=4526that you could use to execute the closure compiler.

如果您想将其全部保留在 IDE 中,看起来 Webstorm 有一个 Ant 插件 http://plugins.intellij.net/plugin/?webide&id=4526可以用来执行闭包编译器。

If you can find a command line css minifier then you could put that in the Ant script as well.

如果您能找到命令行 css minifier,那么您也可以将其放入 Ant 脚本中。

回答by Leigh McCulloch

I use Minify. It's on the Mac App Store.

我使用Minify。它在Mac App Store 上

I developed it to support my own workflow. minifyapp.com

我开发它是为了支持我自己的工作流程。minifyapp.com