3

I have the need to import some javascript files as pure text with webpack.

All the files have a specific extension say: .mytype.js.

I have created a loader for these files using:

module.loaders = [{
  test: /\.mytype.js?$/,
  exclude: /(node_modules|bower_components|public\/)/,
  loader: "mytype-loader"
}, ....]

I have regstered an alias to resolve my own loader

resolveLoader : {
  alias : {
    'mytype-loader' : path.resolve(__dirname, 'myloader.js')  
  }
}

At the moment myloader.js looks like this:

module.exports = source => {
  console.log(source)
  return(source)
}

For my dev server I have the following setup:

   devServer: {

  watchOptions : {

    // I THOUGHT THIS WOULD STOP HOTLOAD CODE BEING ADDED??!
    ignored : path.resolve(__dirname, 'mytypeFiles')
  },

  contentBase: CONTENT_BASE,
  noInfo: true,
  hot: true,
  inline: true,

  port: PORT,
  headers : { 'Access-Control-Allow-Origin' : 'http://localhost:8888'},
  host: HOST
  },

All of my files with extension .mytype.js are in the mytypeFiles directory. The problem is that when I run this I get the following output from the loaders console.log

'use-strict';

function run(args, resources, meta) {
     // a bunch of my code

}
;

var _temp = function () {
    if (typeof __REACT_HOT_LOADER__ === 'undefined') {
            return;
    }

    __REACT_HOT_LOADER__.register(run, 'run', 'D:/manatee-latest/manatee/src/bandicoot/resource-api/bandicoot-functions/run.bandicoot.js');
}();

However use-strict; and everything after the first function definition (which is mine) has been attached. How do I stop this hot loader code from being pre & post-fixed to my source?

Thanks in advance!

Joe
  • 1,455
  • 2
  • 19
  • 36

0 Answers0