Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js - github.com/huyb1991/hugo-lamp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 90da68d76a2b4cbde53e909f2fe6cdf9d703bbd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
 * Copy right: https://gohugo-amp.gohugohq.com/styling/
 */
const sass = require('node-sass'),
      postcss = require('postcss'),
      fs = require('fs'),
      inputFile = './styles/main.scss',
      outputFile = './layouts/partials/stylesheet.html'

sass.render({
  file: inputFile,
  outputStyle: 'compressed'
}, (error, result) => {
  if (error) {
    console.log(error.status);
    console.log(error.column);
    console.log(error.message);
    console.log(error.line);
  } else {
    let cssOutput = result.css.toString();

    postcss([ require('autoprefixer'), require('cssnano') ])
      .process(cssOutput)
      .then((result) => {
        fs.writeFile(outputFile, result.css, err => {
          if (err) {
            return console.log(err);
          }
          console.log('\u2611 file '+outputFile+' updated with current styling from '+ inputFile);
        });
      });
  }
});