简体   繁体   English

不预编译某些资产 - Rails

[英]Not precompile on certain assets - Rails

I have a RoR project in which i have several assets that i don't want them to be precompiled in production mode. 我有一个RoR项目,其中我有几个资产,我不希望它们在生产模式下预编译。 These assets are compound by JS/CSS files and currently they are placed under app/assets/javascript/ism/. 这些资产由JS / CSS文件组成,目前它们位于app / assets / javascript / ism /下。

Actually, it's the whole ism folder which i don't want to compile. 实际上,它是我不想编译的整个ism文件夹。 Though in development mode it's useful and comfortable to keep those files there to work with them, in production mode they shouldn't be there. 虽然在开发模式下保持那些文件与它们一起使用是有用和舒适的,但在生产模式下它们不应该存在。 In production mode those files are all compiled (externally) in a separate file which is served by S3 ant not from RoR/Nginx. 在生产模式下,这些文件都是在一个单独的文件中编译(外部),该文件由S3 ant而不是RoR / Nginx提供。 The externally compiled file is even linked manually, not by RoR. 外部编译的文件甚至是手动链接,而不是RoR。

<script type="text/javascript" src="http://s3.blabla.com/file_compiled.js"></script>

So, what should it be the best way? 那么,它应该是最好的方式呢?

It's less than perfect, however you can prevent these files from being compiled by moving the ism directory out of the asset pipeline and serving them statically. 它并不完美,但是您可以通过将ism目录移出资产管道并静态地提供它们来阻止编译这些文件。 Eg moving /app/assets/javascript/ism/ to /public/ism/ . 例如,移动/app/assets/javascript/ism//public/ism/

If you don't want these files on production at all, you could simply add public/ism/* to your .gitignore file (assuming you're using git). 如果你根本不想要生产这些文件,你可以简单地将public/ism/*添加到你的.gitignore文件中(假设你正在使用git)。

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

相关问题 rake资产:在Windows 8上的rails 3.2.8中预编译失败 - rake assets:precompile failed in rails 3.2.8 on Windows 8 Rails 4资产管道:config.assets.precompile和有条件的javascript - Rails 4 asset pipeline: config.assets.precompile & conditional javascript 由于 Uglifier Punc 错误,无法预编译 Rails 资产 - Can't Precompile Rails Assets Due to Uglifier Punc Error 在我运行 rails assets:precompile 之前,Rails 应用程序不会加载对 Javascript 文件的更新 - Rails app doesn't load updates to Javascript files until I run rails assets:precompile 资产错误:由于ckeditor资产而预编译 - Error on assets:precompile because of ckeditor assets 未定义方法预编译资产错误 - Precompile Assets Error By Undefined Method “rake assets:precompile”的糟糕时间表现 - Poor time performance of 'rake assets:precompile' ExecJS :: ProgramError:尝试为生产预编译资产时出现意外字符&#39;#&#39; - ExecJS::ProgramError: Unexpected character '#' when trying to precompile assets for production 资产期间出错:由于Javascript函数默认参数而预编译 - Error during assets:precompile because of Javascript function default argument 如何使用Rails资产管道预编译picturefill - How to precompile picturefill with rails asset pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM