moyus / laravel-mix-nunjucks

Laravel Mix extension to compile Nunjucks templates
MIT License
11 stars 5 forks source link

laravel-mix-nunjucks runs too late #5

Closed levipadre closed 3 years ago

levipadre commented 4 years ago

I'm using a html minification plugin minify-html-webpack-plugin as well, but unfortunately it couldn't minify the generated html files because laravel-mix-nunjucks haven't finsihed the process yet. We digged into the code, and noticed that in RenderNunjucksTask.js there is a this.renderAll = debounce(this.renderAll) which causes the delay. So by modifying these lines it started to work:

class RenderNunjucksTask extends Task {
  constructor (data) {
    super(data);

    this.options = Object.assign({
      ext: '.html',
      data: {},
      block: 'content',
      marked: null,
      envOptions: null,
      manageEnv: null,
    }, data.options);

    // this.renderAll = debounce(this.renderAll);

and remogin async and await

render(src, dest) {
    //await Promise.resolve();

Can I have a change request for this or any other solution?

levipadre commented 4 years ago

Actually I created a pull request here: https://github.com/moyus/laravel-mix-nunjucks/pull/6

levipadre commented 4 years ago

Hi, can I expect this fixture?

moyus commented 3 years ago

Looks the performance optimization cause this problem, I will do some research to get a better way to resolve your problem in this weekend.

moyus commented 3 years ago

Fixed in v1.1.0