Skip to content

Instantly share code, notes, and snippets.

@stoefln
Created May 10, 2021 06:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save stoefln/d56a5e21a9d4e9431977e059483806c1 to your computer and use it in GitHub Desktop.
const path = require('path')
const webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const SentryCliPlugin = require('@sentry/webpack-plugin')
const { getConfig } = require('./sentryconf')
const sentryConf = getConfig(require('./package.json').version)
console.log('Sentry conf: ', sentryConf)
const rules = [
{
test: /\.node$/,
use: 'node-loader'
},
{
test: /\.js$/,
exclude: /(node_modules|bower_compontents)/,
use: ['babel-loader']
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
const plugins = [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new SentryCliPlugin({
release: sentryConf.release,
include: '.',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'webpack.config.js', 'webpack.production.config.js'],
configFile: 'sentry.properties',
urlPrefix: '~/',
debug: true
})
]
const externals = [
nodeExternals({
whitelist: [/^(?!opencv4nodejs).*/i]
})
]
const noParse = /iconv-loader\.js/
const output = {
filename: '[name]-bundle.js',
sourceMapFilename: '[name]-bundle.js.map',
path: path.resolve(__dirname, 'static'),
publicPath: '/static/'
}
module.exports = [
{
devtool: 'source-map',
entry: {
index: ['@babel/polyfill', './index.js']
},
mode: 'production',
output,
module: {
rules,
noParse
},
plugins,
target: 'electron-main',
node: {
// https://github.com/webpack/webpack/issues/1599#issuecomment-656218316
__dirname: false
},
externals
},
{
devtool: 'source-map',
entry: {
main: ['@babel/polyfill', './app/main.js'],
worker: ['@babel/polyfill', './app/worker.js'],
pdfexport: ['@babel/polyfill', './app/pdfExport.js']
},
mode: 'production',
output,
module: {
rules,
noParse
},
plugins,
target: 'electron-renderer',
externals
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment