Gulp Django-Oscar 3.1.6预制资产的构建失败

llmtgqce  于 2022-12-08  发布在  Gulp
关注(0)|答案(1)|浏览(209)

我正在为django-oscar完成Frobshop 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/目录中。
看起来很简单,所以我输入:

$ 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

运行make assets给了我一个错误消息,抱怨缺少package.json,所以我也从django-oscar中抓到了它。

$ wget -O frobshop/static/package.json \
  https://raw.githubusercontent.com/django-oscar/django-oscar/master/package.json

看起来我应该从新的frobshop/frobshop/static/目录运行make

$ (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.jsdirectory。我是否也应该将其复制到某个地方?
README.rst接着说:x1米20英寸

$ (cd frobshop/static/; npm run watch)

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

hrysbysz

hrysbysz1#

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

相关问题