laravel-mix-replace-in-file
Version:
A simple Laravel Mix extension to allow in-file string replacements.
31 lines (21 loc) • 1.18 kB
Markdown
# Laravel Mix Replace In File
[](https://npmjs.com/package/laravel-mix-replace-in-file)
[](https://www.npmjs.com/package/laravel-mix-replace-in-file)
[](LICENSE)
This extension allows the replacement of strings in files, essentially exposing the functionality provided by the [Replace in file](https://www.npmjs.com/package/replace-in-file) package to Laravel Mix.
## Installation
Install the extension as a development dependency:
````
npm i -D laravel-mix-replace-in-file
````
## Usage
Require the extension and call the `stringReplace` method. For the full set of options available, please refer to the [Replace in file](https://www.npmjs.com/package/replace-in-file) documentation.
````
const mix = require('laravel-mix');
require( 'laravel-mix-replace-in-file' );
mix.replaceInFile( {
files: './dist/script.js',
from: /REPLACE_THIS_STRING/g,
to: 'with_this_string',
} );
````