# @joshmoreno/jigsaw

> tightenco/jigsaw (php package) helper

Latest version **0.1.4** (published 2018-03-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install @joshmoreno/jigsaw
pnpm add @joshmoreno/jigsaw
yarn add @joshmoreno/jigsaw
bun add @joshmoreno/jigsaw
```

Provides the command `jigsaw`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2018-03-18 |
| First published | 2018-03-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 58.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Josh Moreno |
| Maintainers | joshmoreno |
| Keywords | jigsaw |

## Links

- npm: https://www.npmjs.com/package/@joshmoreno/jigsaw
- Repository: https://github.com/JoshMoreno/node-jigsaw
- Issues: https://github.com/JoshMoreno/node-jigsaw/issues
- npm.io page: https://npm.io/package/@joshmoreno/jigsaw

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^4.6.0
- [hasbin](https://npm.io/package/hasbin.md) ^1.2.3
- [chokidar](https://npm.io/package/chokidar.md) ^2.0.2
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^6.0.5

## Recent versions

- 0.1.4 (latest) — 2018-03-18
- 0.1.3 — 2018-03-18
- 0.1.2 — 2018-03-18
- 0.1.1 — 2018-03-18
- 0.1.0 — 2018-03-18

## README

# Introduction
A helper module for the static site generator [Jigsaw](https://github.com/tightenco/jigsaw). This module does three things.
1. Configures the Browsersync webpack plugin for use with Jigsaw.
2. Provides an optimized watcher for rebuilding your Jigsaw site and reloading the browser as files change.
3. Exposes the `Jigsaw` composer command to node for a more fluid build experience. 

## Quick Start
```bash
# npm
npm install @joshmoreno/jigsaw

# yarn
yarn add @joshmoreno/jigsaw 
```

Add the following script to your `package.json`
```json
"scripts": {
	"jigsaw": "jigsaw build production && npm run production"
}
```

Use the sample `webpack.mix.js` below.

**webpack.mix.js**
 ```js
 const mix = require('laravel-mix');
 const jigsaw = require('@joshmoreno/jigsaw');
 
 mix.disableSuccessNotifications();
 
 if (mix.inProduction()) {
     mix.setPublicPath('build_production/assets/');
 } else {
     mix.setPublicPath('source/assets/');
 }
 
 mix.webpackConfig(webpack => {
     return {
         plugins: [jigsaw.browserSync()]
     }
 });
 
 mix.js('source/_assets/js/main.js', 'js/')
     .sass('source/_assets/sass/main.scss', 'css/');
 
 jigsaw.watch();
 ```
 
 ## Api
 ### Browsersync
 ```js
jigsaw.browserSync(browserSyncOptions = {}, pluginOptions = {});
 ```
 
`browserSyncOptions` (object) [Browsersync options](https://browsersync.io/docs/options) to be merged with defaults.

**Defaults**
```js
// const env = argv.e || argv.env || 'local';
// const port = argv.p || argv.port || 3000;
// const buildPath = 'build_' + env;

{
    port: port,
    server: {
        baseDir: buildPath
    },
    serveStatic: ['./source'],
    files: [
        buildPath + '/**/*.html',
        '**/*.css',
        '**/*.js',
    ],
} 
```

`pluginOptions` (object)[browser-sync-webpack-plugin options](https://github.com/Va1/browser-sync-webpack-plugin) to be merged with defaults.

**Defaults**

```js
{
    injectCss: true,
    reload: false,
}
```
#### Return
Returns new `browser-sync-webpack-plugin` instance.

#### Example Usage
See quick start for example usage.

## Jigsaw Build Watcher
```js
jigsaw.watch(paths = ['source/**/*.md', 'source/**/*.php'])
```

`paths` (string | array of strings) Paths to files, dirs to be watched recursively, or glob patterns. See [chokidar.watch docs](https://github.com/paulmillr/chokidar#api) for more info.

#### Example Usage
See quick start for example usage.

## Node Usage
The `jigsaw` command will be available in node just as it is in the command line. It will first look for it locally in your `vendor` directory, then globally in your `PATH`.

All args get passed unmodified so it's really just an alias. You can see an example of it in the quick start section above.

---
_Source: https://npm.io/package/@joshmoreno/jigsaw · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
