index.js 563 B

123456789101112131415161718192021222324
  1. /**
  2. * pupper.js - Webpack Loader
  3. * @author Matheus Giovani <matheus@ad3com.com.br>
  4. * @license AGPL-3.0
  5. */
  6. const Compiler = require("@pupperjs/compiler");
  7. /**
  8. * @param {string} source The source file content
  9. * @param {CompilerOptions} options Any options to be passed to the pupper compiler
  10. * @returns {String}
  11. */
  12. module.exports = function(source, options) {
  13. const contents = Compiler.createCompiler().compileToString(
  14. source,
  15. {
  16. ...options,
  17. fileName: this.resourcePath
  18. }
  19. );
  20. return contents;
  21. };