2

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?

cee.e
  • 159
  • 1
  • 1
  • 9
  • Try to put the content and css keys directly at first level - remove nesting within the extend key – Donkarnash Dec 18 '20 at 10:39
  • Same outcome unfortunately, 3 files all purged. Also just tried options{} rather than extend{} and same again. I can accomplish what I need to by doing 2x prod runs and commenting out bits, but would rather be able to handle everything with a single build – cee.e Dec 18 '20 at 10:45
  • See if https://github.com/spatie/laravel-mix-purgecss helps – Donkarnash Dec 18 '20 at 10:55

0 Answers0