确定哪些资产没有在Rails中使用? [英] Determining which assets are not being used in Rails?

查看:60
本文介绍了确定哪些资产没有在Rails中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails中使用资产管道,我们有很多可能不使用的haml部分,以及未使用的图像.

I'm using the asset pipeline in Rails and we have many haml partials that some are probably not used, along with unused images.

如果不使用资产,例如,如何计算资产图像,Haml等?有自动的找出方法吗?

How do you work out if an asset is not being used, e.g. images, haml, etc.? Is there an automated way to find out?

推荐答案

我找到了一些链接,但还没有尝试过.有机会尝试时,我会回报:

I found some links but haven't tried them yet. I will report back when I get a chance to try them out:

发现未使用的部分

脚本可帮助您找出未使用的部分.适用于大型项目或繁重重构的项目.涵盖Haml和ERB.

A script to help you finding out unused partials. Good for big projects or projects under heavy refactoring. Covers Haml and ERB.

重量

Deadweight 是CSS覆盖工具.给定一组样式表和一组URL,它可以确定实际使用的选择器以及可以安全"删除的报告.

Deadweight is a CSS coverage tool. Given a set of stylesheets and a set of URLs, it determines which selectors are actually used and reports which can be "safely" deleted.

搜索production.log

有一个方便的博客文章,名为查找和删除资产进行grep没见过.

There is a handy blog post called Removing deadweight, describing how to grep through the production log and a script to find and delete assets that have not been seen.

他们使用的grep命令是:

The grep command they use is:

grep -Eo ‘GET /(.*(.gif|.jpg|.jpeg|.png|.css|.js))[ \?]’ access.log > ~/assets.txt

这篇关于确定哪些资产没有在Rails中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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