title: How to use Webpack 2 Raw-Loader to read files
body: <p>I am currently stuck in a spot where I need to start a NodeJS server in HTTPS mode and need to read in the cert files in order to give them as options in the <code>https.createServer(options, app).listen(8443)</code> command.  I am having a hard time grasping onto how to read files into a TypeScript file that is bundled using Webpack 2. 
  For example,</p>
  
  <p>I have 2 files file.crt and file.key.  I want to read these files in when i create the https server and start listening on a given port. In regular TS/JS land I could do this:</p>
  
  <p>```</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import Config from '../env/config';
  import Express from '../lib/express';
  import * as https from 'https';
  
  import * as fs from 'fs';
  
  let config = new Config();
  let app = Express.bootstrap().app;
  
  export default class AppService{
  
    constructor(){
      // console.log('blah:', fs.readFileSync('./file.txt'));
    }
  
    start(){
  
      let options = {
        key: fs.readFileSync('file.key'),
        cert: fs.readFileSync('file.crt'),
        ca: fs.readFileSync('ca.crt'),
        passphrase: 'gulp'
      };
  
      https.createServer(options, app).listen(config.port,()=&gt;{
        console.log('listening on port::', config.port );
      });
  
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>However, when webpack 2 builds the bundle these files arent being brought in, so when node starts up it cant find them.  Ok, i get it, but I read that raw loader will work for this, so i thought i would give it a try.  </p>
  
  <p>Here is my webpack config file:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// `CheckerPlugin` is optional. Use it if you want async error reporting.
  // We need this plugin to detect a `--watch` mode. It may be removed later
  // after https://github.com/webpack/webpack/issues/3460 will be resolved.
  const {CheckerPlugin} = require('awesome-typescript-loader');
  const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
  
  module.exports = {
    target: 'node',
    entry: './src/server.ts',
    output: {
      filename: 'dist/bundle.js'
    },
    resolve: {
      extensions: ['.ts', '.tsx', '.js', '.jsx']
    },
    
    devtool: 'source-map',
    
    module: {
      rules: [
        {test: /\.ts$/, use: 'awesome-typescript-loader'},
        {test: /\.json$/, loader: 'json-loader'},
        {test: /\.crt$/, use: 'raw-loader'}
      
      ]
    },
    plugins: [
      new CheckerPlugin()
    ],
    node: {
      global: true,
      crypto: 'empty',
      fs: 'empty',
      net: 'empty',
      process: true,
      module: false,
      clearImmediate: false,
      setImmediate: false
    }
  };</code></pre>
  </div>
  </div>
  </p>
  
  <p>Which, i think, means ok scan project and when you find any files with .crt then bundle them up with the source map as utf8 strings. All I would have to do is this <code>import crtfile from 'file.crt'</code> just like raw-loader doc states, however, typescript cannot even compile the file now stating it cannot file module file.crt.  Help please!! Ive hit a wall.</p>