0

I am trying to build a Webpack custom loader:

module.exports = function(source) {
  // Transform the source and return it
  console.log('$$$$$$$$$$$$$$$$$$$$$');
  return source;

};

Now, I want to use it in my loaders array, something like:

loaders: [
      {test: /\.vm$/, loader: 'vm-loader', exclude: [/node_modules/, /dist/]}
]

I tried to use resolveLoader's alias, but it did not work:

resolveLoader: {
    alias: {
      "vm-loader": path.join(__dirname, "./lib/velocity-plugin")
    },
    root: [
      path.join(__dirname, 'node_modules'),
      path.resolve('./node_modules')
    ]
  }

What Am I missing?

Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96

1 Answers1

0

Answering my own question:

As it turned out, my custom loader doesn't work because webpack does not work on files which where not required. In my case those html/vm files are not required and not part of the bundle (they are rendered by the server).

My solution was adding gulp in order to have this working. Another (hacky) solution will be using this method

Community
  • 1
  • 1
Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96