Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Pass the loaderContext in the callback #6

Open
dmnsgn opened this issue May 25, 2020 · 1 comment
Open

[Feature request] Pass the loaderContext in the callback #6

dmnsgn opened this issue May 25, 2020 · 1 comment

Comments

@dmnsgn
Copy link
Contributor

dmnsgn commented May 25, 2020

It would be nice if this plugin was matching the html-loader preprocess option: https://github.com/webpack-contrib/html-loader#function

So we can emitError properly if anything goes wrong.

module.exports = {
  module: {
    rules: [
      {
        test: /\.hbs$/i,
        loader: 'html-loader',
        options: {
          preprocessor: (content, loaderContext) => {
            let result;

            try {
              result = processContent(content);
            } catch (error) {
              loaderContext.emitError(error);

              return content;
            }

            return result;
          },
        },
      },
    ],
  },
};
@haoliangyu
Copy link
Owner

Feel free to contribute :) Unfortunately I no longer work in frontend and lose the context to update this tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants