mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-02 20:00:05 +02:00
30 lines
741 B
JavaScript
30 lines
741 B
JavaScript
"use strict";
|
|
|
|
const babelCore = require("@babel/core");
|
|
|
|
const babelPresetMinify = require("babel-preset-minify");
|
|
|
|
module.exports = function babelMinify(input, // Minify options passed to minifyPreset
|
|
// defaults are handled in preset
|
|
options = {}, // overrides and other options
|
|
{
|
|
minified = true,
|
|
inputSourceMap,
|
|
sourceMaps = false,
|
|
sourceType = "script",
|
|
// to override the default babelCore used
|
|
babel = babelCore,
|
|
// to override the default minify preset used
|
|
minifyPreset = babelPresetMinify
|
|
} = {}) {
|
|
return babel.transformSync(input, {
|
|
babelrc: false,
|
|
configFile: false,
|
|
presets: [[minifyPreset, options]],
|
|
comments: false,
|
|
inputSourceMap,
|
|
sourceMaps,
|
|
minified,
|
|
sourceType
|
|
});
|
|
}; |