Laravel Mix and PurgeCss chain, not purging specified file after mix.copy

656 views Asked by At

Trying to build out specific purgedCSS files for a project with rather large complete CSS file. However PurgeCSS refuses to only purge the specified file after mix.copy(), and still purges the main app.css file.

mix.sass('resources/sass/app.scss', 'assets/css').options({
  processCssUrls: false,
  postCss: [],
  autoprefixer: {
    options: {
      browsers: ['last 6 versions']
    }
  }
})
.copy('assets/css/app.css', 'purge/css/home.css')
.purgeCss({
  enabled: true,
  extend: {
    content: [
      path.join(__dirname, '/purge/html/home.html')
    ],
    css: [
      path.join(__dirname, '/purge/css/home.css')
    ]
  }
}).copy('purge/css/home.css', 'assets/css');

The above ends up with 3x CSS files, purged successfully based on the home.html file, however only the copied home.css should be being purged, then copied back to assets/css/home.css.

I've tried using promises after each chain function, but it still refuses to only purge the specified file instead always purging the file compiled with mix.sass() at the top of the chain.

Any ideas?

0

There are 0 answers