# Theme MageSparrow Tasks (With Multi-site Support)
-------------

### Background
This is used by the Magento 2 project scaffold script to create NPM (Node) tasks for a new theme as part of a project setup. 

This can also be used standalone (Download/copy) to compile any Magento 2 Theme as long as Sass files are present.
This task expects to provide a import path for `LibMagesparrow` Sass library, when used for standalone purposes.
This task depends on specific version of NodeJS. To use right version of NodeJs as required by this project check .nvmrc file. 
We recommend to install/use Node Version Manager (NVM) to manage/switch multiple versions of NodeJS.


### Getting Started
```sh
cd vendor/ctidigital/magesparrow-tasks
```

```sh
nvm install && nvm use
```

```sh
npm install --global gulp-cli
```

```sh
npm install
```

### Usage

## Initialise the Magesparrow Child Theme
Warning: This is be used only once, at start of project.

Below command empty Blank Child theme Scaffold to theme directory.

### Interactive mode
Below command empty Blank Child theme Scaffold to app/design/frontend/Cti/<THEME_NAME>-theme

```sh
npm run init:theme 
```

### CLI mode
Below command will create Magento theme using our Blank theme as parent inside a path if it is specified.
THEME_PATH can be absolute or Relative to `magesparrow-task` folder.
Path parameter is Optional and task will fallback automatically resolve the Path to `app/design/frontend/Cti/<THEME_NAME>`

```sh
npm run init:theme -- --name={THEME_NAME} --path={THEME_PATH}
```

Development build
```sh
npm run dev 
```

Production build
```sh
npm run prod 
```

BrowserSync Development
```sh
npm run serve 
```

Compile a specific theme
<THEME_NAME> - must be same as the prefix on sites application.yaml
```sh
npm run build --magesparrow-tasks:theme=<THEME_NAME>
```

### Recommendations

Below recommendations will optimise the local vm to load quicker on local development environments.

1. [Make Redis to accept host connections](https://confluence.ctidigital.com/x/dRYXAg)

2. [Make Varnish accept host connections](https://confluence.ctidigital.com/x/ZhcXAg)

3. [Avoid SSL Certificate Error (in browser) for BrowserSync](https://confluence.ctidigital.com/x/YhYXAg)

4. [Avoid SSL Certificate Error (in browser) for VM domain](https://confluence.ctidigital.com/x/axYXAg)

5. [Upgrade Nginx to allow OpenSSL to support HTTP2 ALPN for Ubuntu 14.04](https://confluence.ctidigital.com/x/cBYXAg)
