summaryrefslogtreecommitdiffstatshomepage
path: root/core/scripts/js/jqueryui-terser.js
blob: f13c703effc4778c51a81eea152b4e501f319d2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const fs = require('fs');
const log = require('./log');
const Terser = require('terser');

module.exports = (filePath) => {
  log(`'${filePath}' is being processed.`);
  // Transform the file.
  const file = fs.readFileSync(filePath, 'utf-8');
  Terser.minify(file).then((result) => {
    fs.writeFile(`${filePath.slice(0, -3)}-min.js`, result.code, () => {
      log(`'${filePath}' is finished.`);
    });
  });
};