jabney / render-template-loader

A webpack loader that renders templates using one of any number of templating engines
MIT License
4 stars 2 forks source link

Partials not reloaded with webpack devServer #9

Open sylvainbaronnet opened 4 years ago

sylvainbaronnet commented 4 years ago

Hello,

I have an issue, twig partials are not reloaded (even refreshing the browser manually). here the rule I use :

      {
        test: /\.twig$/,
        use: [
          {
            loader: 'render-template-loader',
            options: {
              engine: 'twig',
              locals: {
                title: 'Render Template Loader',
              },
              engineOptions: function(info) {
                return {filename: info.filename, path: info.filename};
              },
            },
          },
        ],
      },

with

    new HtmlWebpackPlugin({
      filename: 'test.html',
      template: 'src/twig/test.twig',
    }),
  ],

thanks in advance for your help

sylvainbaronnet commented 4 years ago

Same with ejs and same issue without hot reload

jabney commented 4 years ago

Thanks for the report. I'll have a look when I'm able to get to it. This pr was supposed to address this for Twig, afaik.

Reference: https://github.com/jabney/render-template-loader/pull/6/files#diff-4c2ba0f9edc74c716f857f7c1e86a284R28-R43

https://github.com/jabney/render-template-loader/pull/6/files#diff-14c557625b3ba1fbac7c1a8df28ebeadR40-R45

sylvainbaronnet commented 4 years ago

ok thanks, btw i also had to add this path: info.filename to make it work

vyskoczilova commented 4 months ago

Hi! I know this is an old issue, but is there any fix for loading partials? I tried this config, but somehow, it still doesn't work:

      {
        test: /\.twig$/,
        use: [{
          loader: 'render-template-loader',
          options: {
            engine: 'twig',
            locals: {
              mode: process.env.NODE_ENV || 'development', // Use NODE_ENV or default to 'development'
            },
            engineOptions: function (info) {
              return {filename: info.filename, path: info.filename};
            }
          }
        },]
      },

thanks for any help!