index.js 600 B

1234567891011121314151617181920212223242526
  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. pug: {
  18. filename: this.resourcePath
  19. }
  20. }
  21. );
  22. return contents;
  23. };