mattermost-desktop/webpack.config.base.js
Devin Binnie e1c957e774
Various QoL fixes for Desktop App (#2999)
* Some ESLint fixes

* Add login/logout signal to API, clear mentions on logout and flush cookies on login/logout

* Fix issue where local and HTTP-only servers would not validate correctly

* Reduce noise of renderer logging, adjust a few local renderer logs to be louder when needed

* Fallback to beginning of hostname for servers that don't change the site name

* Fix Save Image crash

* Update the name for insecure servers too

* Fix test

* Fix lint

* Reduce repetition
2024-04-08 09:12:35 -04:00

57 lines
2.2 KiB
JavaScript

// Copyright (c) 2015-2016 Yuya Ochiai
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const childProcess = require('child_process');
const path = require('path');
const webpack = require('webpack');
const VERSION = childProcess.execSync('git rev-parse --short HEAD', {cwd: __dirname}).toString();
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const isRelease = process.env.GITHUB_WORKFLOW && process.env.GITHUB_WORKFLOW.startsWith('release');
const codeDefinitions = {
__HASH_VERSION__: !isRelease && JSON.stringify(VERSION),
__CAN_UPGRADE__: isTest || JSON.stringify(process.env.CAN_UPGRADE === 'true'),
__IS_NIGHTLY_BUILD__: JSON.stringify(process.env.GITHUB_WORKFLOW && process.env.GITHUB_WORKFLOW.startsWith('nightly')),
__IS_MAC_APP_STORE__: JSON.stringify(process.env.IS_MAC_APP_STORE === 'true'),
__SKIP_ONBOARDING_SCREENS__: JSON.stringify(process.env.MM_DESKTOP_BUILD_SKIPONBOARDINGSCREENS === 'true'),
__DISABLE_GPU__: JSON.stringify(process.env.MM_DESKTOP_BUILD_DISABLEGPU === 'true'),
};
codeDefinitions['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV);
if (isTest) {
codeDefinitions['process.resourcesPath'] = 'process.env.RESOURCES_PATH';
}
module.exports = {
mode: isProduction ? 'production' : 'development',
bail: true,
plugins: [
new webpack.DefinePlugin(codeDefinitions),
],
module: {
rules: [{
test: /\.(js|jsx|ts|tsx)?$/,
exclude: /node_modules/,
loader: 'babel-loader',
}],
},
devtool: isProduction ? undefined : 'inline-source-map',
resolve: {
modules: [
'node_modules',
'./src',
],
alias: {
renderer: path.resolve(__dirname, 'src/renderer'),
main: path.resolve(__dirname, './src/main'),
app: path.resolve(__dirname, './src/app'),
common: path.resolve(__dirname, './src/common'),
static: path.resolve(__dirname, './src/assets'),
},
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
},
};