You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
873 B

4 years ago
  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. });