我希望使用 laravel-mix 的 purifyCss。该功能在全新安装上运行良好,但是当我尝试从旧版本的 laravel-mix 升级时,没有任何反应,也没有显示错误。
这是正确的 package.json 文件
{
"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"
}
}
这是我的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');
这是一个测试刀片文件
<!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>
我也在使用yarn
,当我尝试yarn run production
css 时,它永远不会被删除。