Last active
January 12, 2022 17:30
-
-
Save acao/a9f921e72cc425a26794 to your computer and use it in GitHub Desktop.
Webpack example for electron and web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint strict: 0 */ | |
'use strict'; | |
const path = require('path'); | |
const webpack = require('webpack'); | |
const webpackTargetElectronRenderer = require('webpack-target-electron-renderer'); | |
var argv = require('minimist')(process.argv.slice(2)); | |
const isWeb = (argv && argv.target === 'web'); | |
const output = (isWeb ? 'build/web' : 'build/electron'); | |
let options ={ | |
module: { | |
loaders: [{ | |
test: /\.jsx?$/, | |
loaders: [], | |
exclude: /node_modules/, | |
}] | |
}, | |
output: { | |
path: path.join(__dirname, output), | |
publicPath: path.join(__dirname, 'src'), | |
filename: 'bundle.js', | |
}, | |
resolve: { | |
extensions: ['', '.js', '.jsx'], | |
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'], | |
}, | |
entry: [ | |
'./src/index', | |
], | |
debug: true, | |
}; | |
options.target = webpackTargetElectronRenderer(options); | |
module.exports = options; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment