Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chiiya/laravel-mix-filesystem-deployment

Laravel Mix plugin for copying compiled asset files to one or multiple deployment paths on the filesystem.
https://github.com/chiiya/laravel-mix-filesystem-deployment

Last synced: 12 days ago
JSON representation

Laravel Mix plugin for copying compiled asset files to one or multiple deployment paths on the filesystem.

Awesome Lists containing this project

README

        









Laravel Mix Filesystem Deployment



Laravel Mix plugin for copying compiled asset files to one or multiple deployment
paths on the filesystem.



installation
  ·  
usage
  ·  
options
  ·  
example




## Installation

npm install laravel-mix-filesystem-deployment

## Usage

```js
mix.then(async stats => {
const deploy = require('laravel-mix-filesystem-deployment');
await deploy({
deployPaths: ['/home/user/mounts/dev/acme'],
});
});
```

## Options

Configure the plugin by passing an options object as the first argument.

| Option | Default | Details |
| ----------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`deployPaths`** | `[]` | **`REQUIRED`**. List of paths where the assets should be copied to. |
| `stats` | `undefined` | Webpack stats containing information for all compiled assets. **When the stats object is passed, only compiled assets will be copied.** If no stats are passed, all files in the `publicPath` folder matching the `files` pattern are copied. |
| `publicPath` | `dist` | Public path where the compiled assets (and the `mix-manifest.json`) are located. |
| `files` | `['**/*']` | Whitelist of files that should be copied. |
| `clear` | true | Should the `deployPath` directory be cleared before copying files? |
| `manifest` | `mix-manifest.json` inside the `publicPath` folder. | Contents of your `mix-manifest.json` file. |

## Example

The following example copies only the compiled assets during the current webpack
incremental build for development mode, but clears the directory and copies
_all_ files for production mode.

```js
const mix = require('laravel-mix');

const config = {
srcPath: 'src',
distPath: 'dist',
deployPaths: ['/home/user/mounts/dev/acme'],
};

const source = {
images: path.resolve(config.srcPath, 'images'),
scripts: path.resolve(config.srcPath, 'js'),
styles: path.resolve(config.srcPath, 'css'),
templates: path.resolve(config.srcPath, 'templates'),
};

mix.then(async stats => {
const deploy = require('laravel-mix-filesystem-deployment');
await deploy({
clear: Mix.inProduction(),
stats: Mix.inProduction() ? undefined : stats,
deployPaths: config.deployPaths,
});
});
```