quickstart.js 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. });