Comments (4)
That's really why I haven't created a grunt task for this yet. I've had the idea multiple times, but there are some hurdles to overcome I didn't want to deal with.
This is an easy task for static sites, but get's a lot harder when we talk about front-end web apps. You could merge all the CSS files, but you'd still not be entirely sure what rules are being used or not, since you can't programmatically detect all scenarios, even with PhantomJS. Eg. some jQuery plugin that injects classes, etc. And that is going to lead to a lot of confused people with a lot of edge case bugs. I might be thinking inside a box right now, but I can't see any good 100% solution right now.
And if you concatenate the CSS you'll also have to deal with sourcemaps, since most css probably comes from a preprosessor.
Would love a solution for this though as I'm lazy and want the computer to remove moot rules for me.
from grunt-uncss.
The latest version of the task works against multiple files. We're also exploring using PhantomJS to capture the SPA use-cases better over in https://github.com/giakki/uncss/tree/phantomjs.
from grunt-uncss.
I realize this issue has been closed for quite a while, but is there any update for those of us who are trying to fit grunt-uncss into our SPAs? I've got a Durandal app that could greatly benefit from adding this to the build process, but a quick test shows that it removes a lot of necessary styles.
from grunt-uncss.
We've since added support for Phantom. Here's a quick Angular example, although it is a few months old: https://github.com/JeremyCarlsten/grunt-uncss-angular-example. In most cases you will want to use the timeout option specified here https://github.com/addyosmani/grunt-uncss#options to allow your styles to fully load (if they are dynamically being pulled in).
If they require user-interaction in order to display (e.g click a button for a panel to slide out) I recommend isolating that CSS into a stylesheet you ignore UnCSS from processing.
from grunt-uncss.
Related Issues (20)
- Incomplete css HOT 1
- Sync Multiple Vscode?
- Missing dependency of PhantomJS HOT 1
- Regex in src urls HOT 3
- JS errors without inline scripts HOT 1
- Fatal error: Cannot communicate with PhantomJS process: PhantomJS exited unexpectedly: read ECONNRESET HOT 2
- Not taking into account the classes that are added through angular HOT 5
- does it conflict with JQuery HOT 2
- bootstrap alert not processed HOT 1
- Grunt uncss fails silently mac HOT 2
- "ignoreSheets : [/fonts.googleapis/]" isn't ignoring Google fonts HOT 1
- Fatal error: connect ECONNREFUSED 127.0.1.1:80 HOT 2
- Fatal error: uncss/node_modules/css: unable to parse... Excessive slag in URI. HOT 2
- UnhandledPromiseRejectionWarning: Unhandled promise rejection HOT 2
- file.src should be file.orig.src (grunt 1.0.1)
- ignore doesn't work HOT 2
- GitHub Actions CI HOT 3
- Timing Problems with many files HOT 1
- Remove deprecated request package
- Does this work project-wide with SASS files?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-uncss.