问题
Description:
Purifying option doesnt work while compiling css files.Can you explain what is wrong with this approach?
Steps To Reproduce:
This is inside my mix file:
mix.style('resources/assets/css/some.css', 'public/css/some.css').options({
purifyCss: {
paths: ['/home/smolen/Projects/laravel-test/resources/views/welcome.blade.php'],
verbose:true,
minimize:true,
}
})
This is my css file which stay the same after compiling:
.unused-class{
color:red;
}
.used-class{
color:blue;
}
```
This is in my blade file:
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
</head>
<body>
<div class="used-class"></div>
</body>
</html>
回答1:
The purifyOptions are a property of the purifyCss property:
mix.style('resources/assets/css/some.css', 'public/css/some.css').options({
purifyCss: {
purifyOptions: {
paths: ['/home/smolen/Projects/laravel-test/resources/views/welcome.blade.php'],
verbose:true,
minimize:true,
}
}
})
Not super pretty, but it'll do the job I believe.
回答2:
You're setting your options after your processed CSS.
Reverse the order.
来源:https://stackoverflow.com/questions/46074941/purifying-css-assets-via-laravel-mix-doesnt-work