PrestaShop Modern Starter Theme
Table of Contents
About The Theme
Modern prestashop starter theme is made with modern tools such as webpack 4.4, webpack dev server with HMR
List of changes compared to classic theme:
- Bootstrap updated to 4.6 from 4.0.0-alpha.5 - backwards compatibility included.
- Updated webpack to 4.46 from 2.2.1 with whole new webpack config.
- Removed tether - not used anymore with bootstrap 4.6 - popper.js added.
- Removed velocity-animate, jquery.scrollbox.js and jquery-touchswipe - replaced with swiper.
- Removed bootstrap-filestyle.js - replaced with bootstrap custom file input
- Removed jquery.ui from
ps_searchbar
, new moduleis_searchbar
included. - Removed jquery.ui from
ps_facetedsearch
- replaced with nouislider. (ps_facetedsearch
assets unregistered inis_themecore
module). - Added jquery-nice-select to make selects looks better.
Main features:
- Webpack config working properly with webpack dev server and HMR. Watcher also observe changes on
.tpl
templates files and module.css/.js/.tpl
files and make page full reload. You don't need to refresh your webpage anymore to inspect results. - Module
is_themecore
adds structured data with properJSON-LD
format for WebPage, Product, Organization and BreadcrumbList. Also support OpenGraph and Twitter:card. Module add missing breadcrumbs for pages: cart, 404, stores, sitemap. - Dynamic importing boostrap components. You are able to load
.js/.css
file dynamicly with DynamicImportHandler class. There is no docs yet, example of use available in_dev/js/components/dynamic-bootstrap-components.js
. - Lazyload for images added.
- Modified version of
ps_imageslider
included. You are able to upload different images for mobile and desktop. - Multiple entry point for webpack, files separated per view. There are 4 output
js/css
files theme, product, checkout, listing and you are able to add more with ease. If you need rich cms pages with a lot of styles included in it. You don't have to include them everywhere with theme output file. You are able to create another entry e.g. cms and just include it inThemeAssets
class in moduleis_themecore
that handle theme assets. - List/grid listing display. You are able to choose default listing display type. With only few lines of
.js
code. All template changes are handle in.tpl
file. It is also easy to add another list type. - Specific
.scss
file structure that help you maintain your code.
Getting started
Prerequisites
Modules required
System requirements:
- Prestashop requirements,
- vhost setup, to work with starter theme it is required to setup your shop domain with vhost e.g.
starter.test
, - node >= 10v,
- starter tested only on macOS, create an issue if it isn't working with your system.
Installation
- Go to releases and download latest version
.zip
file not source code. - If you want to change theme name unzip file. Change folder name e.g.
your-theme-name
then go toconfig/theme.yml
and change:
name: starter
display_name: display
to:
name: your-theme-name
display_name: my theme display name
Name in theme.yml
must be equal folder name. Zip theme folder and install theme from prestashop BO.
- If you changed theme name you have to go to
is_themecore
module. FindhookActionFrontControllerSetMedia
method and change:
$themeAssetsObject = new ThemeAssets($pageName, 'starter', $this->context);
to:
$themeAssetsObject = new ThemeAssets($pageName, 'your-theme-name', $this->context);
- Open in terminal directory
your-theme-name/_dev
and run:
- for
npm
:
npm install
- for
yarn
:
yarn install
- Go to
your-theme-name/_dev/webpack
and find.env-example
. Copy file and rename it with.env
. Replace example value with proper one based on your setup. - Now try to run:
- for
npm
:
npm run dev
- for
yarn
:
yarn dev
If your .env
file is correctly setup. Your browser will open front office of your store.
Usage
Working with webpack
Webpack config is available in _dev/webpack
folder. Files are structured by their functions:
file | description |
---|---|
webpack.vars.js |
Webpack dev server config that comes from .env file and entry point, output file setup. To add another entry point just add another element to entriesArray , remember to add files /js/{entry_name}.js and /css/{entry_name}.scss . |
webpack.parts.js |
Contains loaders and plugins setup. |
webpack.commons.js |
Config that runs on both production and development. |
webpack.development.js |
Config that runs on development. |
webpack.production.js |
Config that runs on production. |
purge-safelist.js |
Starter theme comes with support for purgecss, but safelist is not included. |
Working with npm/yarn
script | description |
---|---|
build |
Script run production config with assets optimization and chunks names hashing. |
build-purge |
Script run production config with assets optimization, chunks hashing also runs purgecss to remove not used styles. Not recomended to use yet, create safelist before use. |
watch |
Good old watch command that watch your files and compile them. Not HRM and webpack dev server included. Assets optimization not included. |
dev |
Script that run webpack dev server that watch for changes in files and loading them w/o page reload. Script will open your store in browser with port in url, you have to remove it and refresh page. Assets optimization not included. |
scss-fix |
Script that run stylelint and fix minor issues in code. |
eslint-fix |
Script that run eslint and fix minor issues in code. |
Contribution
Any kind of contribution is welcome. Make pull request on develop branch but make sure to create an issue before submitting.