node.jsgruntjshandlebars.jsbrowserifygrunt-browserify

How do I pass arguments to a grunt browserify transform (hbsfy)?


I'm using hbsfy (handlebars templating package) as a transform for browserify in a grunt file. How do I pass the -t or --transform argument to the hbsfy transform?

grunt.initConfig({
  browserify: {
   build: {
    src: 'src/js/app.js',
    dest: 'app.js',
    options: {
      transform: ['browserify-shim', 'hbsfy'],
      browserifyOptions: {
        debug: true,
      },
    },
  },
});

If I were to use browserify conventionally the code would look like:

browserify -t [ hbsfy -t ] main.js > bundle.js

How do I get the -t when using grunt-browserify?


Solution

  • After looking at some of the existing answered issues for grunt-browserify, the following resolved my issue:

     options: {
       transform: ['browserify-shim', ['hbsfy', {'t':[]}]],
     },
    

    I have added hbsfy as an array where the second argument is an options object which contains the empty t option. this allows me to simulate hbsfy -t in grunt-browserify.

    I hope this helps others with the same issue.