Created
May 10, 2021 06:58
-
-
Save stoefln/d56a5e21a9d4e9431977e059483806c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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