问题描述
我在生产服务器上设置了一个典型的 rails 6.0.2 应用程序,我正在使用 git hooks 来部署该应用程序.当我尝试运行时:rails assets:precompile
我收到以下错误:
I have a typical rails 6.0.2 app set up on a production server and I'm using git hooks to deploy the app. When I try to run: rails assets:precompile
I get the following error:
rake aborted!
Sprockets::ArgumentError: link_directory argument must be a directory
/home/user/myapp/app/assets/config/manifest.js:2
这里是 manifest.js 文件
Here is the manifest.js file
//= link_tree ../images
//= link_directory ../stylesheets .css
我不知道我做错了什么.除非我弄错了,webpacker 不会取代链轮吗?
I cant figure out what Im doing wrong. Unless I'm mistaken, doesn't webpacker replace sprockets?
推荐答案
在 manifest.js
中,你的错误告诉 manifest.js
第 2 行,link_directory
参数必须是目录,而不是文件.应该是这样的
In manifest.js
, your error tells that in manifest.js
line 2, link_directory
argument must be a directory, and not a file. It should probably look like this
//= link_directory ../stylesheets .css
如果您注意到stylesheets
和.css
之间存在间隙,这意味着将stylesheetscss
文件链接起来/code> 目录,您的代码中一定存在一些格式问题.修复它,它应该可以工作!
If you notice there is gap between stylesheets
and .css
, it means that link all the css
files from stylesheets
directory, there must be some formatting problem in your code. Fix it and it should work!
这篇关于生产中的 rails 6 webpacker:rake 资产:预编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!