laravel mix extract code example

Example 1: laravel mix purge css

npm install laravel-mix-purgecss --save-dev
  
const mix = require('laravel-mix');
require('laravel-mix-purgecss');

// ...

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .purgeCss(); //Add this line and that'll do the job

Example 2: laravel mix build as umd

mix.js('src/main.js', 'dist/libraryName.js')

mix.webpackConfig({
  output: {
    library: 'libraryName',
    libraryTarget: 'umd',
    umdNamedDefine: true
  }
})

Tags:

Php Example