pages/lib/filters/minifyJs.js

18 lines
308 B
JavaScript
Raw Normal View History

2023-04-02 08:31:07 +00:00
const { minify } = require('terser');
module.exports = (code) => {
if (process.env.NODE_ENV === 'production') {
const minified = minify(code);
if (minified.error) {
console.error('Terser error: ', minified.error);
return code;
}
return minified.code;
}
return code;
};