Filesystem Deployment

Deploy compiled assets to the filesystem.
latest v1.0.0 - released
elishawitte
8 downloads last week
MIT license
1 version

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

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
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.
deployPaths [] REQUIRED. List of paths where the assets should be copied to.

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.

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,
  });
});