问题标签 [django-pipeline]

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 回答
534 浏览

python - django-pipeline with s3 storage is not compressing my js

I'm using django-pipeline with s3. I'm successfully using collectstatic to combined my Javascript files and store them in my s3 bucket, but they are not getting compressed for some reason (verified by looking at the file, its size, and its content-encoding). Otherwise things are working correctly with the combined scripts.js that is produced.

Here are the changes I made to use django-pipeline:

  1. Added pipeline to installed apps.
  2. Added 'pipeline.finders.PipelineFinder' to STATICFILES_FINDERS.
  3. Set STATICFILES_STORAGE = 'mysite.custom_storages.S3PipelineManifestStorage' where this class is as defined in the documentation, as seen below.
  4. Set PIPELINE_JS as seen below, which works but just isn't compressed.
  5. PIPELINE_ENABLED = True since DEBUG = True and I'm running locally.
  6. PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor' even though this should be default.
  7. Installed the Yuglify Compressor with npm -g install yuglify.
  8. PIPELINE_YUGLIFY_BINARY = '/usr/local/bin/yuglify' even though the default with env should work.
  9. Using the {% load pipeline %} and {% javascript 'scripts' %} which work.

More detail:

As mentioned, collectstatic does produce scripts.js just not compressed. The output of that command includes:

I'm using Django 1.8, django-pipeline 1.5.2, and django-storages 1.1.8.

Similar questions:

0 投票
0 回答
273 浏览

django - 在开发机器上测试 django-pipelines

我想在开发过程中测试 django-pipelines(即在只有 django runserver 而没有生产网络服务器的开发机器上)。

通常在开发过程中,只要 Django 提供静态文件DEBUG=True,但如果DEBUG=False. 因此,如果没有合适的网络服务器,我似乎需要保留DEBUG=True我的设置。if通常django-pipelines不做压缩DEBUG=True,但据说可以通过设置来强制PIPELINE_ENABLED=True。因此我的假设是通过设置

我可以在django-pipelines我的开发机器上进行测试。我还添加了

我运行了一个collectstatic,输​​出的css文件被复制到我的STATIC_ROOT(myproj/static_media/static/css/out.css)。但是 Django 不提供这个 css 文件。HTML 寻找它

但它是404s。

尽管如此,当我更改PIPELINE_ENABLED=False(仍然DEBUG=True等)然后手动导航到/site_media/static/css/out.cssDjango 时,就会提供文件。

为什么此设置不起作用,我如何django-pipelines在只有 runserver 的本地开发机器上进行测试?(顺便说一下,这是 django 1.8)。

0 投票
1 回答
268 浏览

css - 在 django-pipeline 中覆盖 Bootstrap

我有一个使用 django-pipeline 包和 bootstrap.css 的 Django 应用程序:

}

正如您在上面看到的,我包含了一个附加文件“bootstrapoverride.css”,我希望用它来覆盖 Bootstrap 的某些功能,例如在我的覆盖文件中:

所以我认为这可能有效,但没有发生覆盖,也许这不可能使用管道。我想避免直接编辑 bootstrap.css 文件。感谢您在这里提供任何见解。

0 投票
1 回答
497 浏览

python - Django Pipeline 生成空文件

我有一个新的 Django 项目,似乎一切正常。我正在使用 Django 管道,但是当我运行“collectstatic”命令时,它会生成所有文件,但我的主要 css 和 js 文件是空白的,而且 js 文件包含...

但没有我的代码。这是我的设置:

0 投票
1 回答
894 浏览

django - django-pipeline DEBUG=True, 未找到压缩文件

好的。我使用 django-pipeline 快疯了,我离完全不使用它只有一步之遥。我还没有生产。以下所有内容都在开发(DEBUG=True)模式下发生。我的 css 静态文件位于名为“project/static/css”的目录中,我将它们收集在名为“project/static_remote/css”的目录中(在我自己的开发服务器中)。

我设置了以下内容:

当我运行collectstatic一切顺利时,master分支中的所有文件(加上压缩文件master.css)都成功复制到“project/static_remote/css”中。直到这里万岁!

但是,当我在我的模板中(显然我有)runserver找不到我的压缩文件时。如果我跑步,同样的事情也适用。为什么会这样?所有其他文件 ( ) 由.{% static 'master' %}href='/static/css/master.css'{% load pipeline %}findstatic 'css/master.css'fonts.css animate.css etcfindstatic

master.css我怀疑这是因为“project/static/css”内部没有副本。还是因为我有这种情况DEBUG = True

如果我手动将“master.css”从“project/static_remote/css”复制到“project/static/css”,那么一切正常,但我不希望这样。请问有什么建议吗?

0 投票
1 回答
3251 浏览

javascript - 未捕获的 ReferenceError:未定义父级

我根据此处的文档使用 django-pipeline 和 browserify -

http://gregblogs.com/how-django-reactjs-and-browserify/

当像这样加载 NPM/Bower 包时,我让它工作得很好 -

问题是我试图在 build.browserify.js 中引用 child.js 和 parent.js

这是3个文件的内容-

child.js

父.js

build.browserify.js

我的浏览器实际上出现了 3 个错误-

我的 child.js 和 parent.js 文件都在第 4 行发生以下情况 -

然后我在第 3 行的 build.browserify.browserified.js 上得到这个

这是该文件的内容 -

编辑 -

如果我像这样将所有代码放在一个 build.browserify.js 文件中,它就可以工作 -

0 投票
1 回答
4629 浏览

javascript - Angular 2 Typescript 编译器错误

我认为是时候在开发中使用 Angular2 了,所以我想开始,但我遇到了 TS 编译器引发的错误。我使用 django-pipelines 和 pipelines-typescript 包。如果我创建一个输出 .js 及其工作的 .ts 文件,编译器似乎可以正常工作。但是当我尝试使用 angular2 时,它会输出“error TS2304: Cannot find name 'Map'”和“'Promise'。\n/Users/bbx/envs/dscn_3/bin/scene/scene/static/angular2/src/facade /promise.d.ts(3,14): 错误 TS2304: 找不到名称 promise":

我的模板是:

app.ts 是

所以我看到它找不到承诺和地图。

0 投票
1 回答
547 浏览

django - 在服务器上编译 Angular 2 打字稿或将 TS 交给转译器之间的区别

我只想从正确的角度 2 开始。我正在使用 django 和 django-pipeline。我尝试了管道打字稿模块,该模块将所有 .ts 文件编译为 .js 文件。但是我无法运行它,由于错误,是我的问题,所以我仍然无法正常工作!

所以现在我只是按照官方教程并让它在服务器上运行而无需编译

所以我的问题是,这样做是否是正常的生产设置,只需将我所有的问题留给转译器,或者我需要修复我的打字稿编译器并且文件需要是 JS。用打字稿和缩小+可能混淆构建项目的正确方法是什么。Django-pipeline 完成了我梦寐以求的一切,但我无法让它与 Angular 一起运行,但 typescript 编译正常。

0 投票
1 回答
199 浏览

django-pipeline - Django-pipeline 语法无效

我正在尝试在我的测试项目中设置 django-pipeline,但是,我遇到了一个没有明显解决方案的错误。这是 settings.py 中的管道配置

从配置中可以看出,此设置将允许 collectstatic 毫无问题地运行。但是,如果我取消注释这些行,collectstatic 将失败。错误如下所示您已请求在设置中指定的目标位置收集静态文件:

非常感谢您的帮助。

0 投票
0 回答
380 浏览

django - 从 django-pipeline 编译的 SASS 没有被静态文件找到,即使它存在

我已经配置django-pipeline如下:

collectstatic在调试模式下运行并启动了服务器,以查看一切是否设置正确。我可以访问我所有的图像和脚本,但不能访问已编译的 CSS 文件。我的静态设置:

更多观察:

我怎样才能staticfiles找到编译好的 CSS 文件?