How to use the @node-minify/utils.utils.readFile function in @node-minify/utils

To help you get started, we’ve selected a few @node-minify/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github srod / node-minify / packages / babel-minify / src / babel-minify.js View on Github external
const minifyBabel = ({ settings, content, callback, index }) => {
  let babelOptions = {
    presets: []
  };

  if (settings.options.babelrc) {
    babelOptions = JSON.parse(utils.readFile(settings.options.babelrc));
  }

  if (settings.options.presets) {
    const babelrcPresets = babelOptions.presets || [];
    babelOptions.presets = babelrcPresets.concat(settings.options.presets);
  }

  if (babelOptions.presets.indexOf('minify') === -1) {
    babelOptions.presets = babelOptions.presets.concat([minify]);
  }

  const contentMinified = transform(content, babelOptions);
  if (!settings.content) {
    utils.writeFile({ file: settings.output, content: contentMinified.code, index });
  }
  if (callback) {