我很难理解django-compressor的使用.
这是我想要完成的事情:
我想将我的LESS CSS和Coffeescript文件分成资产目录
例如
app
??? assets
??? coffee
? ??? script.coffee
??? less
??? style.less
Run Code Online (Sandbox Code Playgroud)
将静态资产(如图像)保留在静态目录中
例如
app
??? static
??? hello.txt
??? photo.jpg
Run Code Online (Sandbox Code Playgroud)
为此,我已将资源路径添加到我的STATICFILES_DIRS变量,以允许django-compressor查找文件(按预期工作).这是正确的方法吗?我一直试图找到一个专用于django-compressor的独立加载路径,但没有任何运气,因为我不打算将这些资产用作静态.
为了部署到生产,我希望将编译好的CSS和JS文件以及我的app/static目录中的其他媒体(例如图像等)收集到app/static-prod目录中.但这并不是很好,因为在使用collectstatic命令时也会收集资产.
例如
(django-cpython)fots@fotsies-ubprecise-01:~/django_learning$ ./manage.py collectstatic --noinput
Copying '/home/fots/django_learning/app/assets/less/style.less'
Copying '/home/fots/django_learning/app/assets/less/import.less'
Copying '/home/fots/django_learning/app/assets/coffee/script.coffee'
Copying '/home/fots/django_learning/app/static/photo.jpg'
Copying '/home/fots/django_learning/app/static/hello.txt'
5 static files copied.
Run Code Online (Sandbox Code Playgroud)
使用该./manage.py compress命令只需要记录我编译的文件,而不是本例中的photo.jpg或hello.txt.
我发现这样做的唯一可行方法是使用带有collectstatic的--ignore标志
例如
(django-cpython)fots@fotsies-ubprecise-01:~/django_learning$ ./manage.py collectstatic --noinput --ignore=less --ignore=coffee
Copying '/home/fots/django_learning/app/static/photo.jpg'
Copying '/home/fots/django_learning/app/static/hello.txt'
2 static files copied.
Run Code Online (Sandbox Code Playgroud)
我也搞乱了COMPRESS_ROOT和COMPRESS_URL配置变量,但这些只会造成进一步的麻烦.更改COMPRESS_ROOT可解决collectstatic问题,但现在使用compress命令时,生成的文件最终位于静态文件的不同位置.
这些解决方案似乎并不优雅 有一个更好的方法吗?我觉得我错过了什么.
在此先感谢任何帮助:)
我一直在尝试解决这个问题一段时间,想知道您是否可以提供帮助。
使用 AppleScript,系统事件应用程序中有两个隐藏功能可用,它们允许您按下一个键(在其他操作完成时按住它),然后再次将键重新打开。
例如,请参阅此处的答案Applescript 以运行检测显示,其中在执行单击时使用“向上键”和“向下键”。
但是为了这个例子,让我们使用一些非常简单的东西,一个保存快捷方式。
AppleScript 看起来像这样:
tell application "System Events"
key down command
keystroke "s"
key up command
end tell
Run Code Online (Sandbox Code Playgroud)
我在 JXA 中最接近的如下,但无论我传递给 keyDown 什么,它都会发送字母“a”:
events = Application("System Events")
events.keyDown("command")
events.keystroke("s")
events.keyUp("command")
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢!
福蒂斯