# Files & Directories

# mix.copy()

interface RenameOptions {
  dirname?: string;
  prefix?: string;
  basename?: string;
  suffix?: string;
  extname?: string;
}

interface HookOptions {
  src?: object; // = `gulp.src`
  rename?: string | Function | RenameOptions;
}

mix.copy(input: string | string[], output: string, options?: HookOptions)

🌰 For example:

const api = (mix) => {
  mix.copy('app/old-filename.html', 'dist', {
    rename: {
      basename: 'new-filename',
      suffix: '.blade',
      extname: '.php'
    }
  });

  mix.copy(['app/foo/*', 'app/bar/**/*'], 'dist/copied', {
    src: {
      base: '.'
    }
  });
};

module.exports = (balm) => {
  return {
    config: {},
    api
  };
};

Reference gulp.src options (opens new window)

# mix.remove()

mix.remove(paths: string | string[])

Delete files/directories.

🌰 For example:

const api = (mix) => {
  mix.remove('foo.txt');
  mix.remove(['bar/a.txt', 'bar/b.txt']);
};

module.exports = (balm) => {
  return {
    config: {},
    api
  };
};

# mix.replace()

interface ReplaceOptions {
  substr?: string | RegExp;
  replacement?: string | Function;
}

mix.replace(input: string | string[], output: string, options: ReplaceOptions | ReplaceOptions[])

New in 2.9.0

Update options: ReplaceOptions[] in 2.10.0

Last Updated: 4 years ago