Comments (4)
I'm investigating.
Some points.
The main source of the issue is the missing from
options (doc) in the postcss.parse()
call (doc).
Then we have to ask ourselfs whether the sourcemap generation is responsibility of the postcss engine or we can delegate it to the clean-css optimizer.
Both are able to generate source maps but the two scenarios are pretty divergent.
In the first case (postcss responsibility), at the moment I came to the following observations:
the clean-css tool should be passive, we have to give him each source separately, so it can minify their css strings one at time, it shouldn't inline @import
statements itself, and return the minified styles so to leave to the postcss engine the responsibility to join the various roots. It will then generate automatically the sourcemap.
I have still to think about the 2nd scenario.
Anyway, since the time is spare, discussions, ideas, help, or PRs are welcome! Thanks.
from postcss-clean.
Because in theory clean-css could be inserted anywhere in the chain and not necessarily last, it'd make sense if postcss remained responsible for generating source maps. Parsing files individually and ignoring imports sounds prudent to me. (I handle imports earlier in the plugin chain anyway.)
However, clean-css would lose part of its appeal: it's great for merging and eliminating redundancies across rules and presumably across files, an ability which would be crippled if handling files separately. Delegating source map generation to it would create a big exception to how postcss is structured, but would solve that. Perhaps if that special delegation had to be explicit in one's postcss.config.js
, it could be an acceptable way to go…
from postcss-clean.
I have hit this problem too, however, I don't understand why it touches the sourcesContent at all, this need to remain to match the original source files.
Example file:
html, body {
height: 100%;
width: 100%;
}
/*.row {
display:flex;
flex-direction: row;
}
.column {
display: flex;
flex-direction: column;
}*/
.sticky {
position: sticky;
}
Source Map with postcss-clean in the chain:
{
"version": 3,
"sources": [
"<input css 1>"
],
"names": [],
"mappings": "AAAA,UAAU,YAAY,UAAU,CAAC,QAAQ,eAAe,CAAC",
"file": "cache/modd/style/test.scss-out.css",
"sourcesContent": [
"body,html{height:100%;width:100%}.sticky{position:sticky}"
]
}
and without it
{
"version": 3,
"sources": [
"cache/modd/style/test.scss"
],
"names": [],
"mappings": "AAAA;EACC,aAAY;EACZ,YAAW,EACX;;AAED;;;;;;;GAOG;AACH;EACC,iBAAgB,EAChB",
"file": "cache/modd/style/test.scss-out.css",
"sourcesContent": [
"html, body {\r\n\theight: 100%;\r\n\twidth: 100%;\r\n}\r\n\r\n/*.row {\r\n\tdisplay:flex;\r\n\tflex-direction: row;\r\n}\r\n.column {\r\n\tdisplay: flex;\r\n\tflex-direction: column;\r\n}*/\r\n.sticky {\r\n\tposition: sticky;\r\n}\r\n"
]
}
It appears that clean css is not just cleaning the output, but also manipulating the source map in such a way, that makes it unreadable. I have tried adjusting sourceMap settings, with no success.
from postcss-clean.
Used with gulp-postscss
The same issue <input css 2>
Config
{
rebase: false,
format: {
breaks: {
afterRuleEnds: true
}
}
}
from postcss-clean.
Related Issues (20)
- Correct the jsnext:main field of package.json HOT 1
- Task to bundle ES2015 module
- Automate changelog generation
- Clean task
- Code coverage support
- Use of const in strict mode (node 0.12.x)
- Correctly send coverage lcov info to coveralls
- Fix travis-ci for older node versions
- Use module field within the package.json
- Evaluate the usage of the peer dependencies
- Increase back the coverage up to 100%
- Upgrade to clean-css 4
- ::part(a b c) compiles to ::part(abc) HOT 3
- postcss 8 breaks this? HOT 4
- Some styles were lost after "clean"
- Version 1.2.0 is breaking HOT 10
- Issue on postcss 8, node.getIterator() is not a function HOT 14
- Could you help update postcss in 1.2.3 release?
- postcss plugin - postcss.config.js
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 postcss-clean.