问题标签 [grunt-contrib-cssmin]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
13034 浏览

gruntjs - 我们如何在 grunt cssmin 任务中设置目标?

我正在为 Grunt试用cssmin

根据文档,可以“根据 grunt 配置任务指南”定义目标。当我使用该模式创建 cssmin 任务时,例如:

未创建缩小文件。

如果我删除目标级别,它会按预期工作。我在这里做错了吗?或者除了cssmin还有其他选择(在我的研究中,我选择了这个,因为每个人都指向它)

使用:

  • 咕噜声 v0.4.1
  • cssmin v0.6.0
0 投票
1 回答
1258 浏览

javascript - Grunt, TypeError: Object has no method 'Split'

I'm setting up Grunt for the first time and it has all been going smoothly (using Chris Coyier's 24 Ways article: http://24ways.org/2013/grunt-is-not-weird-and-hard/).

Go figure, I step off the beaten path and I'm running into issues. I installed cssmin to minify my already concatenated CSS, and I'm getting:

Using --force also fails (Warning: css minification failed.)

I was able to install, configure and use concat, uglify and imagemin without issues. Here is my simplified grunt file to try to isolate the issue:

I've also tried using the specific examples from the documentation, but I get the same 'split' error regardless of which I try:

https://github.com/gruntjs/grunt-contrib-cssmin

Any help is appreciated!

0 投票
6 回答
8660 浏览

css - cssmin 没有正确处理@import

我在包含 @imports 的文件上使用 cssmin。cssmin 正确递归地导入本地文件,但对于指向 URL 的导入,导入保留为内联。这使得生成的缩小 CSS 无效,因为 @ 规则必须在文件的开头。有谁知道这个问题的好解决方案或解决方法?

0 投票
1 回答
212 浏览

gruntjs - Grunt css min 文件扩展名

我正在使用 grunt 来缩小 CSS。

但是,当我尝试更改缩小数组中的参数时

我无法缩小 CSS。'.min' 重要吗?

我的 gruntfile 如下

0 投票
2 回答
8779 浏览

gruntjs - .min.css 文件的 Grunt cssmin

我正在使用 grunt 和 cssmin 来缩小我的 css。

但是,在我的 css 资产文件夹中,我有一些具有 .min.css 扩展名的 css。因此,当我运行 grunt 时,只有源文件夹中带有 .css 的文件才会被缩小到构建文件夹中。源文件夹中包含 .min.css 的文件将在 build 文件夹中找到,但 .min 扩展名将丢失。即 bootstrap.min.css 将变为 bootstrap.css

我的 Gruntfile.js 如下

有什么方法可以缩小 .min.css 文件并保留在 build 文件夹中并保留正确的 '.min.css' 扩展名?

0 投票
1 回答
271 浏览

git - Grunt cssmin 不使用 jquery 缩小文件前缀

我有一些以'jquery'为前缀的css文件。例如,'jquery-fancybox.css'

我正在使用 grunt cssmin 来缩小 css,并使用预提交 git 钩子,我能够运行缩小。

我也在服务器上做了一个 post-receive git hook,所以当我做一个 pull 时,它也会缩小。

当我在做 pre-commit git 钩子时,那些带有前缀 'jquery' 的 css 文件可以被缩小,但不能在 post-receive git 钩子中。

知道为什么吗?

我的咕噜声文件如下

0 投票
1 回答
267 浏览

gruntjs - 将 grunt-usemin 与 Mean.io 一起使用(单独的 public/ 和 app/ 文件夹)

我使用 yeoman 角度生成器创建了一个新项目,然后我对其进行了一定程度的修改以满足我自己的需要。但是后来我意识到我想使用 mean.io 来支持 express 和 mongodb。我花了很长时间将必要的部分从 mean.io 默认项目复制到我自己的项目中。但是,我仍然面临 grunt-rev 和 grunt-usemin 的严重问题。

最初的 yeoman 生成的项目有 app/ 文件夹,其中包含所有 AngularJS 项目。然而,新项目有 app/ 文件夹用于服务器中存在的所有项目,然后是 public/ 文件夹用于客户端所需的所有项目。现在 grunt-rev 插件重命名 css 和图像文件以包含一些与该项目的版本匹配的标识符。我认为这非常有用,所以我想将它保留在我的项目中。接着; 我的 index.html 位于 app/ 文件夹中,所有的 CSS 和图像都在 public/ 文件夹中。在我的 index.html 中,我得到了类似“<img src="images/imagename.png">“。这在我通过启动节点 express 服务器测试项目时有效,因为它从服务器根目录的同一位置同时提供 app/views/ 和 public/。但是 Usemin 不理解这一点,因为图像源不t 匹配绝对文件夹结构。我试图将 app/views/ 内容移动到 app/,但无济于事。使用 cssmin 构建的 css 文件也会发生同样的情况。我在 index.html 中获得了属性,并且在该属性下我的所有 css . 构建之后,我在那里得到了styles/main.css,但由于usemin没有意识到文件夹结构,我最终在index.html中得到了styles/main.css,在styles/中得到了986a2d75.application.css。

有什么方法可以让 usemin 知道应该像处理一个文件夹一样处理两个文件夹?我发现您可以强制 usemin 查找特定模式,但这会迫使我记住将每个图像分别添加到 gruntfile,所以在我这样做之前我宁愿根本不使用这些插件。

0 投票
1 回答
1751 浏览

css - 使用 Grunt 处理依赖文件并重写路径

这是我的Gruntfile.jsassetsBower文件夹):

一切正常,但正如我所怀疑的那样,Font-awesome 在使用grunt-contrib-mincss.

我可以用 Grunt 自动化它会做类似的事情吗?

  • 将字体文件从复制assets/font-awesome/fonts/dist/fonts/
  • 重写url(../fonts/url(fonts/

提前致谢!

0 投票
1 回答
441 浏览

javascript - Grunt un-css 忽略 java-script 生成的 css

我是新来的 grunt 并用于 java-script 和 css 放大。这只是一个很棒的工具。在探索了更多的咕噜声之后,我遇到了 uncss 模块,它可以帮助改善 css 的加载时间和大小(尤其是像 bootstrap css 这样的框架)。

我有 angular 和 php 应用程序,它有一个由 php 和 java-script 动态生成的类。在运行 uncss 时,这个 css 选择器将从生成的新 css 文件中删除。

我想我在安装 grunt 的 uncss 模块时已经安装了 phantom-js。

谁能知道我如何做到这一点。

0 投票
2 回答
2124 浏览

gruntjs - grunt-contrib-cssmin missing _stream_transform module

I get the following error when trying to run css minification from GruntJs and I have no clue why.

What is the origin of this error message? I've search through the cssmin.js file and can't find a single reference to that module.