Laravel-mix: Webpack configuration with mode

Created on 24 Nov 2018  路  2Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 2.1.14 (npm list --depth=0)
  • Node Version (node -v): 10.13.0
  • NPM Version (npm -v): 6.4.1
  • OS: Windows 10
  • Description:

    Can't configure the webpack mode='production'

    Steps To Reproduce:

    This is my webpack.mix.js file:

    let mix = require('laravel-mix');
    
    mix.js('resources/assets/js/app.js', 'public/js')
       .sass('resources/assets/sass/app.scss', 'public/css');
    
    mix.webpackConfig({
        mode: 'production'
    });
    

    then i ran npm run dev

    It produced this error:

    Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
     - configuration has an unknown property 'mode'. These properties are valid:
       object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
       For typos: please correct them.
       For loader options: webpack 2 no longer allows custom properties in configuration.
         Loaders should be updated to allow passing options via loader options in module.rules.
         Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
         plugins: [
           new webpack.LoaderOptionsPlugin({
             // test: /\.xxx$/, // may apply this only for some modules
             options: {
               mode: ...
             }
           })
         ]
    

    Most helpful comment

    Laravel mix is using webpack 3.
    i think mode was introduced in webpack 4

    All 2 comments

    Laravel mix is using webpack 3.
    i think mode was introduced in webpack 4

    Should be resolved with laravel mix v4

    Was this page helpful?
    0 / 5 - 0 ratings

    Related issues

    Cheddam picture Cheddam  路  3Comments

    amin101 picture amin101  路  3Comments

    rlewkowicz picture rlewkowicz  路  3Comments

    hasnatbabur picture hasnatbabur  路  3Comments

    rderimay picture rderimay  路  3Comments