如何建立开发环境来构建prestashop主题资产?

问题描述

根据Prestashop's documentation,我正在尝试构建Prestashop classic主题的资产。我在Windows 10上使用cygwin。这是我详细执行的操作:

  • 我派出了最新的稳定标签(1.7.6.7)。
  • 我在./tools/assets/build.sh中运行了cygwin。 (我也在Windows Terminal和step by step中尝试过,即cd主题目录,后跟npm install。)

npm install抛出错误,抱怨缺少Python

gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python",you can set the PYTHON env variable.
  • 我安装了Python 3,并收到错误消息,抱怨缺少Python 2.7

  • 我安装了python 2.7,并因抱怨缺少Visual Studio 2008而报错。

      Projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln" sur le noud 1 (cibles par défaut).
      ValidateSolutionConfiguration:
        Génération de la configuration de solution "Release|x64".
      MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed,either 1) install the Microsoft 
      Windows SDK for Windows Server 2008 and .NET Framework 3.5,or 2) install Microsoft Visual Studio 2008.  
      [E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln]
      Génération du projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln"
      terminée (cibles par défaut) -- ÉCHEC.
    

在继续尝试和尝试之前,我想问一问是否有人知道为Prestashop主题设置完整的开发环境需要哪些先决条件。或者更确切地说,在能够运行npm install之前我必须安装的软件列表是什么?

https://devdocs.prestashop.com/显然没有提供任何线索,它们仅说明npmcomposer here的安装。

有人在设置Prestashop开发环境方面有经验吗?感谢您的帮助。

解决方法

经典主题使用webpack来编译资产,更多信息: https://devdocs.prestashop.com/1.7/development/compile-assets/

最好的方法是导航到themes/classic/_dev并运行npm install :)之后,您可以使用npm run watchnpm run build或任何其他定义的脚本

,

答案不是直接的:

主题使用node-sass,该主题使用node-gyp编译。

正如readme of node-gyp所述,在Windows上,我们需要安装npm install --global --production windows-build-tools,它可以处理Python和Visual Studio。

Prestashop 1.7.6.7最新稳定发行版的主题使用带有节点12.x的node-sass版本(^4.11.0which is not compatible

因此,我们需要安装nvm for windows并使用最新版本的节点10.x分支。

通过这些步骤,npm install将起作用。

npm run build将失败,因为npm脚本与Windows不兼容。 代替npm run build(调用NODE_ENV=production webpack --progress --colors --debug --display-chunks),我们必须运行

set NODE_ENV=production
npx webpack --progress --colors --debug --display-chunks

Prestashop开发人员似乎从未尝试过在Windows上运行他们的工作。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...