gulp - Django-Oscar 3.1.6 Frobshop 资产的构建失败
问题描述
我正在研究Frobshop 示例django-oscar
项目。
关于自定义资产的django-oscar
文档相当简洁,而我报告的未解决的错误manage.py oscar_fork_statics
只会增加混乱。这是我(失败的)手动复制文件和编译资产的尝试。
我在/var/work/django/frobshop/
.
django-oscar
我为in安装了一个虚拟环境/var/work/django/oscar/
,因此在该目录中可以找到分发的资产目录 in lib/python3.8/site-packages/oscar/static/oscar/
。该README.rst
目录中的文件说When building your own project, it is not recommended to use these files straight from the package. Rather, you should take a static copy of the ``oscar/static/oscar`` folder and commit it into your project.
看起来很简单,所以我输入:
$ cd /var/work/django
$ mkdir frobshop/frobshop/static/
$ cp -a lib/python3.8/site-packages/oscar/static/oscar/* frobshop/frobshop/static/
接下来README.rst
说:You can compile the static assets from the root of the project using a make target: make assets
。
$ make assets
make: *** No rule to make target 'assets'. Stop.
嗯,那没用。https://github.com/django-oscar/django-oscar/blob/master/Makefile是正确的吗Makefile
,我想知道它应该放在哪里?
$ wget -O frobshop/static/Makefile \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/Makefile
Runningmake assets
给了我一条错误消息,抱怨缺少package.json
,所以我也从中获取了它django-oscar
。
$ wget -O frobshop/static/package.json \
https://raw.githubusercontent.com/django-oscar/django-oscar/master/package.json
好像我应该make
从新frobshop/frobshop/static/
目录运行:
$ (cd frobshop/static/; make assets)
安装了许多文件,然后最终出现此消息:
found 3 vulnerabilities (2 moderate, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm run build
> django-oscar@3.0.0 build /var/work/django/frobshopCamille/frobshop/static
> gulp copy && gulp scss
[11:32:39] No gulpfile found
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! django-oscar@3.0.0 build: `gulp copy && gulp scss`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the django-oscar@3.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mslinn/.npm/_logs/2021-02-19T16_32_39_097Z-debug.log
make: *** [Makefile:29: assets] Error 1
我不知道如何处理该错误。我看到一个名为. 我也应该把它复制到某个地方吗?django-oscar
gulpfile.js
README.rst
接着说:If you make changes to Oscar's assets in development, you can run ``npm run watch`` to automatically watch and compile changes to them.
$ (cd frobshop/static/; npm run watch)
当然,这只会产生与以前相同的错误消息。
解决方案
中提到的编译资产(使用make assets
,运行 Gulp 任务)的说明src/oscar/static_src/oscar/README.rst
实际上仅适用于开发/打包django-oscar
自身时。我们将努力使文档更加清晰。
对于基于 django-oscar 的项目/商店,您只需要运行./manage.py collectstatic
, 即可使用 Oscar 的静态文件而无需修改,如下所述:https ://django-oscar.readthedocs.io/en/latest/howto/how_to_handle_statics.html #customising-statics
要修改和覆盖 Oscar 的静态文件,您还需要运行./manage.py oscar_fork_statics
, 将 Oscar 的静态文件复制到您的项目中。该命令当前已损坏,但我们正在修复:https ://github.com/django-oscar/django-oscar/pull/3657
推荐阅读
- c++ - 如何将 lambda 返回的浮点数组插入到浮点向量中?
- python - 在 Windows 上使用 python -m pip install 和 numpy(用于 tensorflow 对象检测)的编译器错误
- r - 如何在 R 中使用 shinyDirButton 选择多个文件夹
- sql - HIVE - 基于日期计算分区的统计信息
- c# - xUnit - 取消测试时未调用 Collection Fixture 类的 Dispose 方法
- javascript - 对格式不正确的日期进行排序
- python - 删除重复条目并提取所需信息
- embedded-linux - 致命错误:无效 -march= 选项:'armv5t'
- rest - 找不到404的问题如何解决?
- vb.net - 如何使用 tls 和 vb.net API post call 通过 sendgrid 发送加密电子邮件?