laravellaravel-mixpurifycss

laravel-mix purifyCss option not working


im looking to use the purifyCss of laravel-mix. The fuction is working fine on a brand new installation but when i try to upgrade from an older version of laravel-mix nothing happens and no errors are shown.

this is the currect package.json file

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "cross-env": "^5.1",
    "laravel-mix": "^2.0",
    "popper.js": "^1.13.0",
    "purify-css": "^1.2.6",
    "purifycss-webpack": "^0.7.0"
  },
  "dependencies": {
    "bootstrap": "^4.0.0",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "normalize.css": "^8.0.0",
    "velocity-animate": "^2.0.1"
  }
}

this is my webpack.mix.js

let mix = require('laravel-mix');

mix.options({
    purifyCss: true
});

//default path
mix.setPublicPath('website');

//index
mix.sass('resources/assets/sass/index/index-desktop.scss', 'css/index/index-desktop.min.css');

and this is a test blade file

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ session('user.language_code') }}">
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Caudex" rel="stylesheet">
    <link rel="stylesheet" href="{{ asset('css/index/index-desktop.min.css') }}">

</head>
<body>

</body>
</html>

Also im using yarn and when i try yarn run production the css is never removed.


Solution

  • The problem has been solved.

    For anyone having the same problem check your class/id and be sure they dont have any numbers on it.