Page does not load when using webpacked bundle for main.js


#1

I am using some es7 features for which I need to transpile the code using babel. Rather than do this at runtime, I want to transpile the code and make a bundle which I can then use directly. Runtime transpiling makes the app just a tad bit slow on Startup. For this, I tried to use webpack. Here is the config for the main process:

let config = {
  target:'electron',
  entry:'./bootstrapper.js',
  output:{
    path:path.resolve(__dirname, 'dist'),
    filename: 'electronmainbundle.js',
    publicPath:'/dist/'
  },
  resolve: {
    extensions:["",".js",".json"]
  },
  externals: {
    'pouchdb':"require('pouchdb')",
  },
  module: {
    noParse: /node_modules\/json-schema\/lib\/validate\.js/,
    loaders:[{
      test: /\.js?$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    },
      {
        test: /\.json/,
        loader: 'json-loader',
      },
    ],
  },
}

module.exports = config;

As you will notice, I am using the target:‘electron’ in my config which allows one to require electron related modules. This does work as the browserWindow does come up when the app is ready. However, the index.html does not load with the error:

Not allowed to load local resource: file://index.html/

I found a similar issue opened on github at [https://github.com/electron/electron/issues/5107] (https://github.com/electron/electron/issues/5107) however, that does not have a solution. I also did not find any other articles, questions etc when I googled this issue.

Has anyone even been able to use webpacked bundle for main.js of the main process? Or any idea how to fix this issue?