Laravel-mix: How to add custom webpack config options?

Created on 2 Jun 2017  路  4Comments  路  Source: JeffreyWay/laravel-mix

I am using laravel mix, but i also want to add some extra custom webpack config options

How do I go about adding it?

watchOptions: {
  aggregateTimeout: 2000,
  poll: 2000,
  ignored: /node_modules/
}

This is the watch options I would like to add. But i don't quite understand how to modify the packaged webpack.config.js.

I can obviously fork it and use that version, but how do I simply extend it?

All 4 comments

@ankurk91 Thanks. This is exactly what i was looking for.

Could you share your final config file, with these watch options implemented. @liuzhen2008 ? I'm having trouble getting this working, and trying to do the exact same as you.

@benyanke Hey. I think I did was

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');


mix.webpackConfig({
  watchOptions: {
    aggregateTimeout: 2000,
    poll: 2000,
    ignored: /node_modules/
  }
});

Was this page helpful?
0 / 5 - 0 ratings