webdiscus / html-bundler-webpack-plugin

Alternative to html-webpack-plugin ✅ Renders Eta, EJS, Handlebars, Nunjucks, Pug, Twig templates "out of the box" ✅ Resolves source files of scripts, styles, images in HTML ✅ Uses a template as entry point
ISC License
147 stars 15 forks source link

Webpack build is silent when cache.type = 'filesystem' #115

Closed DimaGashko closed 4 weeks ago

DimaGashko commented 4 weeks ago

Current behaviour

I know it's experimental, but I just not sure if it's expected behavior for now or not. When I set cache.type = 'filesystem' the build doesn't have any logs in the terminal.

Here I run the build a few times - with cache.type=memory, cache.type=filesystem, and one more time after deleting the cache directory. Only first time I get any output in the terminal. Each time I got the correct build.

image

If the build fails (e.g. change the img path to non-existing), I still see no errors, but when I fix the issue and try to rebuild (or just rebuild instantly) - it fails.

When I delete the plugin and uncomment the entry property of the config - everything is working as expected.

Expected behaviour

I expect to see the same output in the terminal as usual, and also I expect the build to fail when there was problems during the build.

Reproduction

Config I used for testing:

const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');

/** @type {import('webpack').Configuration} */
module.exports = {
   mode: 'production',
   // entry: './src/index.js',
   output: {
      path: `${__dirname}/dist`,
      clean: true,
   },
   stats: {
      preset: 'normal',
      children: true,
   },
   resolve: {
      extensions: ['.js'],
      alias: {
         '@': `${__dirname}/src`,
      },
   },
   cache: {
      // type: 'memory',
      type: 'filesystem',
      buildDependencies: {
         config: [__filename],
      },
   },
   module: {
      rules: [{
         test: /\.(png|jpe?g|webp|avif|svg|gif|ico)$/i,
         type: 'asset/resource',
      }],
   },
   plugins: [
      new HtmlBundlerPlugin({
         entry: {
            'index': './src/index.html',
         },
      }),
   ],
};

Environment

Additional context

p.s. what also your predictions/plans for cache.type=filesystem? Will it be fully supported sometime in the future? In a year, two, n years? So we can understand what to expect.

webdiscus commented 4 weeks ago

Hello @DimaGashko,

thanks for the issue report. Can you please create a small repo with reproducible issue?

P.S.

The supports of filesystem caching is experimental because I cannot guarantee 100% functionality in all use cases. The filesystem caching is very very complex to integrate with this powerful plugin on all levels. Thanks to the issues reported by users, I can implement missing or incorrect functionality. Yes of cause I will release the supports of filesystem caching, it is very important feature, but I need help of community to test it and report issues.

Feel you free to create feature requests or a bug issues.

DimaGashko commented 4 weeks ago

Here's the repo: https://github.com/DimaGashko/html-bundler-plugin.filesystem

image

webdiscus commented 4 weeks ago

@DimaGashko

yes, I can reproduce the issue. I will research the "silent mode" and try to fix it.

Using memory caching: image

Using filesystem caching: image

webdiscus commented 4 weeks ago

@DimaGashko

currently you can use the verbose: true plugin option to display all precessed assets:

new HtmlBundlerPlugin({
      entry: {
        index: './src/index.html',
      },
      verbose: true,
    }),

The plugin has own verbose to display all entry points and dependencies:

image

webdiscus commented 4 weeks ago

@DimaGashko the issue is fixed in the v4.1.3

DimaGashko commented 4 weeks ago

@webdiscus looks great. The output is displayed as expected. When the build fails as well. And even more - the cache was broken after failed build but now it works properly as well.

Thanks for that fast response and even fix!