JS API example not working
See original GitHub issueHi there. I have a problem… I cant understand how readme example is supposed to work:
var postcss = require('postcss');
postcss([ require('autoprefixer'), require('cssnano') ])
.process(css, { from: 'src/app.css', to: 'app.css' })
.then(function (result) {
fs.writeFileSync('app.css', result.css);
if ( result.map ) fs.writeFileSync('app.css.map', result.map);
});
What is css
? In the doc you write It is a String with input CSS…
but if I have to read my input file and place it as a string to css
argument, what is options.from
then?
Also, why I should write app.css
file in promise then
? What is options.to
then?
Issue Analytics
- State:
- Created 7 years ago
- Comments:20 (14 by maintainers)
Top Results From Across the Web
Why is the API not working correctly? - Stack Overflow
I am new to JavaScript and API's so I can't solve this problem.. Here's the the javascript and the form part of the...
Read more >Introduction to web APIs - Learn web development | MDN
Browser APIs are built into your web browser and are able to expose data from the browser and surrounding computer environment and do...
Read more >Node.js v19.3.0 Documentation
In most cases, AsyncLocalStorage works without issues. In rare situations, the current store is lost in one of the asynchronous operations. If your...
Read more >Error Messages | Maps JavaScript API - Google Developers
Check that the API key you currently use on your website is listed. If that's not the case, switch to a different project,...
Read more >API - esbuild
If you still run into cross-platform quote escaping issues with different ... For example, assume you have a file called process-shim.js that exports...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Diokuz
@Diokuz I thought about file system shortcut. But it is unnecessary in most of cases:
gulp-postcss
gets file content via Gulp API.postcss-loader
gets file content via webpack API.fs
.In result there is no good reason to some
postcss().readAndWrite()
shortcut. Anyway most of PostCSS runners will get file content by other way.