quickstart.js 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * This example targets Node 4 and up.
  3. */
  4. const cssnano = require('cssnano');
  5. /*
  6. * Add your CSS code here.
  7. */
  8. const css = `
  9. h1 {
  10. color: #ff0000;
  11. font-weight: bold;
  12. }
  13. `;
  14. /*
  15. * Add any PostCSS options here. For example to enable sourcemaps, see:
  16. * https://github.com/postcss/postcss/blob/master/site/source-maps.md
  17. *
  18. * Or for an inline sourcemap, uncomment the options below.
  19. */
  20. const postcssOpts = {
  21. // from: 'app.css',
  22. // to: 'app.min.css',
  23. // map: {inline: true},
  24. };
  25. /*
  26. * Add your choice of preset. Note that for any value other
  27. * than 'default', you will need to install the appropriate
  28. * preset separately.
  29. */
  30. const cssnanoOpts = {
  31. preset: 'default',
  32. };
  33. /*
  34. * Compress the CSS asynchronously and log it to the console.
  35. */
  36. cssnano.process(css, postcssOpts, cssnanoOpts).then(result => {
  37. console.log(result.css);
  38. });