I have a very simple setup with electron and webpack. I’m trying to use the target electron-renderer but seems I cannot load electron in the app js file (electron-renderer process). I suspect it has something to do with the correct webpack config setup.
I keep getting this error: Uncaught ReferenceError: require is not defined
Lib versions:
webpack: 1.13.1
electron-prebuilt: 1.2.0
Here is my app repository: https://github.com/Cecildt/electron-webpack
Here is my webpack.config.js details:
var path = require('path');
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
module.exports = {
devtool: 'source-map',
debug: true,
entry: {
'app': './src/index.ts'
},
output: {
path: __dirname + '/build/',
publicPath: 'build/',
filename: '[name].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['','.ts','.js','.json', '.css', '.html'],
modulesDirectories: ['node_modules']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'ts',
exclude: [ /node_modules/, /releases/ ]
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(css|html)$/,
loader: 'raw'
},
{
test: /\.(png|jpg)$/,
loader: 'url?limit=10000'
}
]
},
plugins: [
new webpack.ExternalsPlugin('commonjs', ['electron'])
],
externals: [
],
target:'electron-renderer'
};
Hope somebody can help me! Thanks in advance.
+1
+1.