How to use oc-hash-builder - 3 common examples

To help you get started, we’ve selected a few oc-hash-builder 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 opencomponents / oc-template-react / packages / oc-template-react-compiler / lib / compileView.js View on Github external
compiler(config, (err, data) => {
      if (err) {
        return cb(err);
      }

      const memoryFs = new MemoryFS(data);
      const bundle = memoryFs.readFileSync(
        `/build/${config.output.filename}`,
        "UTF8"
      );

      const bundleHash = hashBuilder.fromString(bundle);
      const bundleName = "react-component";
      const bundlePath = path.join(publishPath, `${bundleName}.js`);
      const wrappedBundle = reactComponentWrapper(bundleHash, bundle);
      fs.outputFileSync(bundlePath, wrappedBundle);

      let css = null;
      if (data.build["main.css"]) {
        // This is an awesome hack by KimTaro that will blow your mind.
        // Remove it once this get merged: https://github.com/webpack-contrib/css-loader/pull/523
        css = fontFamilyUnicodeParser(
          memoryFs.readFileSync(`/build/main.css`, "UTF8")
        );

        // We convert single quotes to double quotes in order to
        // support the viewTemplate's string interpolation
        css = minifyFile(".css", css).replace(/\'/g, '"');
github opencomponents / oc-template-react / packages / oc-template-react-compiler / lib / compileView.js View on Github external
fs.outputFileSync(cssPath, css);
      }

      const reactRoot = `oc-reactRoot-${componentPackage.name}`;
      const templateString = viewTemplate({
        reactRoot,
        css,
        externals,
        bundleHash,
        bundleName
      });

      const templateStringCompressed = production
        ? templateString.replace(/\s+/g, " ")
        : templateString;
      const hash = hashBuilder.fromString(templateStringCompressed);
      const view = ocViewWrapper(hash, templateStringCompressed);
      return cb(null, {
        template: { view, hash },
        bundle: { hash: bundleHash }
      });
    });
  };
github opencomponents / oc-template-react / packages / oc-template-react-compiler / lib / compileServer.js View on Github external
err =>
            next(
              err,
              err
                ? null
                : {
                    type: "node.js",
                    hashKey: hashBuilder.fromString(
                      compiledFiles[publishFileName]
                    ),
                    src: publishFileName
                  }
            )
        )

oc-hash-builder

Hash builder utility

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Popular oc-hash-builder functions