[Solved] Cannot find module "ipc" with webpack built


#1

Hi, I’m building a project with electron and webpack. I send something with window.webContents.send in main process, and receive it through ipc module in render process. But I met an error cannot find moudle "ipc" in render process when I require it, it’s likely something fault in webpack. Here’s my configuration file of webpack (webpack.config.js):

var path = require('path'),
    webpack = require('webpack');

module.exports = {
    entry: {
        app: ['webpack/hot/dev-server', './app/main.js'],
    },
    output: {
        path: path.resolve(__dirname, 'build'),
        filename: 'bundle.js',
    },
    devServer: {
        contentBase: path.resolve(__dirname, 'build'),
        publicPath: '/build/'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            },
            {
                test: /\.less$/,
                loader: 'style-loader!css-loader!less-loader'
            },
            {
                test: /\.(otf|eot|svg|ttf|woff|woff2)(\?.+)$/,
                loader: 'url-loader?limit=8192'
            }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.IgnorePlugin(new RegExp("^(fs|ipc)$"))
    ]
}

Does anyone can help me? Thanks.


#2

Problem solved! Just add target to configuration:

{
    "target": "atom"
}