Default theme for VirtoCommerce Storefront used by Electronics sample store. It includes the largest number of features and support latest updates of Storefront so it always stay actual.
- Install prerequisites.
- Clone repo.
- In Visual Studio, go to
Team Explorer
→Clone
→ Enter https://github.com/VirtoCommerce/vc-default-theme.git as URL andD:\vc-default-theme
(for example) as path. - Or execute command
git clone https://github.com/VirtoCommerce/vc-default-theme.git "D:\vc-default-theme"
(whereD:\vc-default-theme
is path to folder where you want to clone repo).
- In Visual Studio, go to
- Link you theme repo to store. Execute:
mklink /d "C:\vc-platform-master\VirtoCommerce.Platform.Web\App_Data\cms-content\Themes\Electronics\default" "D:\vc-default-theme"
mklink /d "C:\vc-storefront-master\VirtoCommerce.Storefront\App_Data\cms-content\Themes\Electronics\default" "D:\vc-default-theme"
(whereC:\vc-platform-master\VirtoCommerce.Platform.Web\App_Data\cms-content
andC:\vc-storefront-master\VirtoCommerce.Storefront\App_Data\cms-content
are paths tocms-content
folders on platform and storefront,Electronics
is your store name andD:\vc-default-theme
is path to your theme repo). - Open theme folder in your IDE
- In Visual Studio (including 2017) go to
File
→Open
→Website
- In Visual Studio Code, go to
File
→Open
→Folder
- Select
D:\vc-default-theme
(whereD:\vc-default-theme
is path to folder where you want to clone repo) and open it.
- In Visual Studio (including 2017) go to
- Install node.js dependencies.
- In Visual Studio all dependencies will be installed automatically. Just wait a few minutes.
- In Visual Studio Code and other editors, you need to run
npm install
to install Node.js dependencies.
You need to have local installation of storefront. Follow this article step-by-step to install storefront from binaries or source code.
Note: Currently we're in process of moving default theme to separate repository and bundles updating. So you need to install storefront from dev
branch. Follow the article above to learn how.
If you have Visual Studio 2015 with Update 3 and above, you don't need install any prerequisites. Latest versions of Node.js and Gulp already included in your Visual Studio installation and supported in built-in Task Runner Explorer.
Task Runner Explorer, Node.js and Gulp already included in your Visual Studio installation. However, you need update your Node.js to at least 4.0.0.
- Update Node.js to v4.0.0 at least (we recommend latest LTS version). Use
C:\Program Files\nodejs
installation path (changeProgram Files
toProgram Files (x86)
on 64-bit machine). - Add Node.js installation path to External Web Tools or move $(PATH) to top:
You need install:
- Task Runner Explorer Visual Studio extension
- Install Node.js v4.0.0 or above (we recommend latest LTS version)
npm install gulp -g
- Install Node.js v4.0.0 or above (we recommend latest LTS version)
npm install gulp -g
Attention: while theme including bundlesconfig.json
file, you must not use Bundler & Minifier Visual Studio extension with theme. See Appendix: bundling & minification process workflow
for details about why.
Bundling & minification will work automatically when you save file and on build.
Tip: if bundling & minification failed, you, probably, need to run gulp watch
task manually after that. Go to Task Runner Explorer
(in Visual Studio) and click Run
on task watch
.
Bundling & minification will work automatically on build. If you want to automatically bundle & minify files on save, please, install & configure Blade Runnner Visual Studio Code extension.
Tip: if bundling & minification failed, you, probably, need to run gulp watch
task manually after that. Go to Command Palette (Ctrl+Shift+P)
and type task watch
then press Enter.
Run gulp watch
on command line if you want to bundle & minify files on save or run gulp default
manually when you need to bundle & minify theme files.
{{ 'bundle/scripts.js' | static_asset_url | append_version | script_tag }}
static_asset_url
means that this file is static content of site;script_tag
orstylesheet_tag
will generate<script ... >
or<link rel="stylesheet" ... >
tags;append_version
is used to correctly invalidate browser cache for bundles, make sure that it's added afterstatic_content_url
(or other url filter), not at the end, for example.
default
: default task. Bundles and minifies theme files.clean
: removes bundled & minified files.lint
: runseslint
to check for warnings & errors in javascript files. Look at eslint site for details.min
andmin:js
,min:css
,min:html
: minify all or specified types of files.watch
: watching to any changes on bundled & configuration files and update bundles when any change occurs.compress
: creates zip package with all needed files to deploy theme on storefront.
We're using gulp to bundle & minify files on theme, because it support a lot of possible customizations and has a plugins for css minification and correct source maps generation. Wrong source map generation and lack of css minification is a primary reason why we do not use Bundler & Minifier extension in Visual Studio.
When you run the default
task to bundle & minify theme, the following happens:
- ESLint runs and output warnings and errors in javascript code.
- Javascript minifies and source maps generates.
- CSS processes by Autoprefixer with the following browsers support (documentation may be sometimes outdated; browser versions specified in gulpfile then specified in docs, not vice versa).
- CSS minifies and source maps generates.
Copyright (c) Virtosoftware Ltd. All rights reserved.
Licensed under the Virto Commerce Open Software License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://virtocommerce.com/opensourcelicense
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.