首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django-Oscar 3.1.6 Frobshop资产的构建失败

Django-Oscar 3.1.6 Frobshop资产的构建失败
EN

Stack Overflow用户
提问于 2021-02-20 00:39:56
回答 1查看 150关注 0票数 0

我正在使用django-oscarFrobshop sample project

在定制资产方面,django-oscar文档相当简洁,而the unresolved bug I reported for manage.py oscar_fork_statics只是增加了混乱。这是我手动复制文件和编译资产的尝试(失败)。

我在/var/work/django/frobshop/中安装了Frobshop。

我在/var/work/django/oscar/中为django-oscar安装了一个虚拟环境,因此可以在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.

看起来很简单,所以我输入了:

代码语言:javascript
复制
$ 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

代码语言:javascript
复制
$ make assets
make: *** No rule to make target 'assets'.  Stop.

嗯,那不管用。我想知道,https://github.com/django-oscar/django-oscar/blob/master/Makefile是合适的Makefile吗?它应该放在哪里?

代码语言:javascript
复制
$ wget -O frobshop/static/Makefile \
  https://raw.githubusercontent.com/django-oscar/django-oscar/master/Makefile

运行make assets会给我一条错误消息,抱怨package.json丢失,所以我也从django-oscar获取了它。

代码语言:javascript
复制
$ wget -O frobshop/static/package.json \
  https://raw.githubusercontent.com/django-oscar/django-oscar/master/package.json

似乎我应该从新的frobshop/frobshop/static/目录运行make

代码语言:javascript
复制
$ (cd frobshop/static/; make assets)

安装了许多文件,然后最终出现以下消息:

代码语言:javascript
复制
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.jsdirectory。我应该把它也复制到什么地方吗?

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.

代码语言:javascript
复制
$ (cd frobshop/static/; npm run watch)

当然,这只会产生与之前相同的错误消息。

EN

回答 1

Stack Overflow用户

发布于 2021-02-22 20:30:30

src/oscar/static_src/oscar/README.rst中提到的编译资源的说明(使用make assets,它运行Gulp任务)实际上只在开发/打包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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66281559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档