Gathering detailed insights and metrics for laravel-mix-purgecss
Gathering detailed insights and metrics for laravel-mix-purgecss
Gathering detailed insights and metrics for laravel-mix-purgecss
Gathering detailed insights and metrics for laravel-mix-purgecss
npm install laravel-mix-purgecss
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
874 Stars
196 Commits
38 Forks
10 Watching
1 Branches
29 Contributors
Updated on 29 Oct 2024
Minified
Minified + Gzipped
JavaScript (77.1%)
CSS (10.32%)
Shell (7.35%)
Blade (5.23%)
Cumulative downloads
Total Downloads
Last day
4.3%
2,097
Compared to previous day
Last week
-2.9%
9,343
Compared to previous week
Last month
9.1%
41,050
Compared to previous month
Last year
3.3%
503,656
Compared to previous year
This package adds a purgeCss
option to Laravel Mix, which installs PurgeCSS for you with a set of sensible defaults for Laravel applications.
1const mix = require('laravel-mix'); 2require('laravel-mix-purgecss'); 3 4// ... 5 6mix.js('resources/js/app.js', 'public/js') 7 .sass('resources/sass/app.scss', 'public/css') 8 .purgeCss();
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Before you get started, make sure you're using laravel-mix
version 5.0.0 or higher.
You can install the package with yarn or npm:
1yarn add laravel-mix-purgecss --dev
1npm install laravel-mix-purgecss --save-dev
Then install the extension by requiring the module in your Mix configuration.
1const mix = require('laravel-mix'); 2require('laravel-mix-purgecss'); 3 4// ...
PurgeCSS can be enabled by calling .purgeCss()
in your Mix chain.
1mix.js('resources/js/app.js', 'public/js') 2 .sass('resources/sass/app.scss', 'public/css') 3 .purgeCss();
By default, PurgeCSS only works when building assets for production. You can override this behaviour by specifying the enabled
option.
1mix.js('resources/js/app.js', 'public/js') 2 .sass('resources/sass/app.scss', 'public/css') 3 .purgeCss({ 4 enabled: true, 5 });
mix.postCss
or postcss.config.js
usersWhen you use mix.postCss()
or a seperate postcss.config.js
file, Mix overrides all other PostCSS plugins, including the PurgeCSS instance added by this plugin.
To work around this issue, either:
mix.options()
1 const mix = require('laravel-mix'); 2 require('laravel-mix-purgecss'); 3 4 mix.js('resources/js/app.js', 'public/js') 5- .postCss('resources/sass/app.css', 'public/css', [ 6- require('tailwindcss')(), 7- ]) 8+ .postCss('resources/sass/app.css', 'public/css') 9+ .options({ 10+ postCss: [require('tailwindcss')] 11+ }) 12 .purgeCss();
postcss-purgecss-laravel
instead1 const mix = require('laravel-mix'); 2- require('laravel-mix-purgecss'); 3 4 mix.js('resources/js/app.js', 'public/js') 5 .postCss('resources/sass/app.css', 'public/css', [ 6 require('tailwindcss')(), 7+ require('postcss-purgecss-laravel')({ /* ... */ }), 8 ]) 9 .purgeCss();
Custom options can be passed when calling PurgeCSS if necessary. Visit PurgeCSS' docs to learn more about the available options.
1mix.js('resources/js/app.js', 'public/js') 2 .sass('resources/sass/app.scss', 'public/css') 3 .purgeCss({ 4 content: [path.join(__dirname, 'vendor/spatie/menu/**/*.php')], 5 safelist: { deep: [/hljs/] }, 6 });
Passing options will override the package defaults. If you want to extend the package defaults, wrap them in an extend
object.
1mix.js('resources/js/app.js', 'public/js') 2 .sass('resources/sass/app.scss', 'public/css') 3 .purgeCss({ 4 extend: { 5 content: [path.join(__dirname, 'vendor/spatie/menu/**/*.php')], 6 safelist: { deep: [/hljs/] }, 7 }, 8 });
This package uses postcss-purgecss-laravel
under the hood, which has the following defaults:
1const defaultConfig = { 2 content: [ 3 "app/**/*.php", 4 "resources/**/*.html", 5 "resources/**/*.js", 6 "resources/**/*.jsx", 7 "resources/**/*.ts", 8 "resources/**/*.tsx", 9 "resources/**/*.php", 10 "resources/**/*.vue", 11 "resources/**/*.twig", 12 ], 13 defaultExtractor: (content) => content.match(/[\w-/.:]+(?<!:)/g) || [], 14 safelist: { standard: [/-active$/, /-enter$/, /-leave-to$/, /show$/] }, 15}
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.
We publish all received postcards on our company website.
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
The MIT License (MIT). Please see License File for more information.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/21 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More