index.js 902 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Copy right: https://gohugo-amp.gohugohq.com/styling/
  3. */
  4. const sass = require('node-sass'),
  5. postcss = require('postcss'),
  6. fs = require('fs'),
  7. inputFile = './styles/main.scss',
  8. outputFile = './layouts/partials/stylesheet.html'
  9. sass.render({
  10. file: inputFile,
  11. outputStyle: 'compressed'
  12. }, (error, result) => {
  13. if (error) {
  14. console.log(error.status);
  15. console.log(error.column);
  16. console.log(error.message);
  17. console.log(error.line);
  18. } else {
  19. let cssOutput = result.css.toString();
  20. postcss([ require('autoprefixer'), require('cssnano') ])
  21. .process(cssOutput)
  22. .then((result) => {
  23. fs.writeFile(outputFile, result.css, err => {
  24. if (err) {
  25. return console.log(err);
  26. }
  27. console.log('\u2611 file '+outputFile+' updated with current styling from '+ inputFile);
  28. });
  29. });
  30. }
  31. });