Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
Some components in PrestaShop, like Javascript or SCSS files, need to be compiled to be usable.
We use Webpack to compile assets. PrestaShop is using NodeJS (get it here), NPM will take care of it all.
Here is a list of compatibility:
PrestaShop Versions | NodeJS Versions | NPM Versions |
---|---|---|
9.x | 20.x | 8.x |
If you can not manage to compile assets, you may be using an older version of PrestaShop. We strongly recommend you to install a package such as ’n’ or nvm to try with an older version of NodeJS.
On Windows, you will probably need to install windows-build-tools
using npm i --global windows-build-tools
in order to make node-gyp working.
admin-dev/themes/default/sass
admin-dev/themes/new-theme/scss
admin-dev/themes/new-theme/js
themes/_core/js
themes/classic/_dev/css
themes/classic/_dev/js
Subproject | Path |
---|---|
Default theme | cd admin-dev/themes/default/ |
New theme | cd admin-dev/themes/new-theme/ |
FO Core | cd themes/ |
Classic theme | cd themes/classic/_dev/ |
Run npm install (first time only)
npm install
Run webpack
npm run build
You can rebuild all the assets at once by executing this command from the project root:
./tools/assets/build.sh
# or alternatively
make assets
You can also make webpack listen for changes and compile only what’s needed as you work on your files:
npm run watch
Rebuild your changes before committing.
The “watch” build will optimize your assets for development. Please remember to rebuild for production when you are done using npm run build
.
If npm install
fails with error: Failed at the ... postinstall script.
:
You may be using an old version or one we don’t support yet. As of 8.0, every folder containing a package.json is compatible with node 12. How we manage to work with this, as well as working on previous PrestaShop version, is that we use a tool to easily swap between node version.
There are a lot of tools able to do this. At PrestaShop, we mainly use the ’n’ package or nvm.
This is pretty easy to use, when you are working on a directory which need an older or newer node version, use one of these tools to switch and then npm install && npm run build
.