通过Laravel Mix净化CSS资产不起作用 [英] Purifying css assets via laravel mix doesnt work
本文介绍了通过Laravel Mix净化CSS资产不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在编译css文件时,Purifying选项不起作用.您能解释一下这种方法有什么问题吗?
Purifying option doesnt work while compiling css files.Can you explain what is wrong with this approach?
这在我的混合文件中:
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,
}
})
这是我的css文件,编译后保持不变:
.unused-class{
color:red;
}
.used-class{
color:blue;
}
```
这在我的刀片文件中:
<!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>
推荐答案
purifyOptions是purifyCss属性的属性:
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.
这篇关于通过Laravel Mix净化CSS资产不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文