2021-05-12 06:35:00 +00:00
|
|
|
// recommended by the docs: https://webpack.js.org/configuration/configuration-languages/
|
|
|
|
// just in case you run into any typescript error when configuring `devServer`
|
|
|
|
import 'webpack-dev-server';
|
|
|
|
|
2021-07-22 23:04:56 +00:00
|
|
|
import path from 'path';
|
2021-09-02 21:15:52 +00:00
|
|
|
import { Configuration, DefinePlugin, NormalModuleReplacementPlugin, optimize } from 'webpack';
|
2021-07-22 23:04:56 +00:00
|
|
|
|
|
|
|
import pkg from '../package.json';
|
|
|
|
|
2021-05-12 06:35:00 +00:00
|
|
|
const configuration: Configuration = {
|
2016-03-22 05:01:58 +00:00
|
|
|
devtool: 'source-map',
|
2016-03-16 20:02:47 +00:00
|
|
|
context: path.join(__dirname, '../app'),
|
2021-05-12 06:35:00 +00:00
|
|
|
entry: ['./renderer.ts', './renderer.html'],
|
2016-03-16 20:02:47 +00:00
|
|
|
output: {
|
2021-02-03 07:07:11 +00:00
|
|
|
path: path.join(__dirname, '../build'),
|
2016-04-20 02:14:53 +00:00
|
|
|
filename: 'bundle.js',
|
2018-12-12 17:36:11 +00:00
|
|
|
libraryTarget: 'commonjs2',
|
2016-03-16 20:02:47 +00:00
|
|
|
},
|
|
|
|
module: {
|
2017-02-26 21:12:51 +00:00
|
|
|
rules: [
|
2016-03-16 20:02:47 +00:00
|
|
|
{
|
2021-05-12 06:35:00 +00:00
|
|
|
test: /\.tsx?$/,
|
2021-11-03 08:06:52 +00:00
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'babel-loader',
|
2016-04-16 23:24:57 +00:00
|
|
|
},
|
2016-03-16 20:02:47 +00:00
|
|
|
{
|
2016-08-29 17:58:59 +00:00
|
|
|
test: /\.(less|css)$/,
|
2017-02-26 21:12:51 +00:00
|
|
|
use: [
|
|
|
|
'style-loader',
|
2018-06-25 17:42:50 +00:00
|
|
|
{ loader: 'css-loader', options: { importLoaders: 1 } },
|
2018-12-12 17:36:11 +00:00
|
|
|
{ loader: 'less-loader', options: { noIeCompat: true } },
|
|
|
|
],
|
2017-02-26 21:12:51 +00:00
|
|
|
},
|
|
|
|
{
|
2017-03-03 01:44:07 +00:00
|
|
|
test: /\.(html|woff2)$/,
|
2017-02-26 21:12:51 +00:00
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2018-12-12 17:36:11 +00:00
|
|
|
name: '[name].[ext]',
|
|
|
|
},
|
2017-03-03 01:44:07 +00:00
|
|
|
},
|
|
|
|
{
|
2020-04-26 20:33:39 +00:00
|
|
|
test: /\.(png|svg)$/,
|
2018-12-12 17:36:11 +00:00
|
|
|
loader: 'url-loader',
|
|
|
|
},
|
2021-01-28 10:46:19 +00:00
|
|
|
{
|
|
|
|
test: require.resolve('../app/network/ca-certs.js'),
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'val-loader',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-12-12 17:36:11 +00:00
|
|
|
],
|
2016-03-16 20:02:47 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
2019-04-18 00:50:03 +00:00
|
|
|
alias: {
|
2020-06-13 04:56:15 +00:00
|
|
|
// Create aliases for react-hot-loader
|
|
|
|
// https://github.com/gaearon/react-hot-loader/tree/92961be0b44260d3d3f1b8864aa699766572a67c#linking
|
|
|
|
'react-hot-loader': path.resolve(path.join(__dirname, '../node_modules/react-hot-loader')),
|
2021-05-12 06:35:00 +00:00
|
|
|
react: path.resolve(path.join(__dirname, '../node_modules/react')),
|
2020-08-12 01:51:37 +00:00
|
|
|
'styled-components': path.resolve(path.join(__dirname, '../node_modules/styled-components')),
|
2020-06-13 04:56:15 +00:00
|
|
|
'react-dom': path.resolve(path.join(__dirname, '../node_modules/@hot-loader/react-dom')),
|
2019-04-18 00:50:03 +00:00
|
|
|
},
|
2021-05-12 06:35:00 +00:00
|
|
|
extensions: ['.js', '.json', '.ts', '.tsx'],
|
2018-12-12 17:36:11 +00:00
|
|
|
mainFields: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
|
2016-04-15 16:50:29 +00:00
|
|
|
},
|
2017-11-04 20:53:40 +00:00
|
|
|
node: {
|
2018-12-12 17:36:11 +00:00
|
|
|
__dirname: false, // Use Node __dirname
|
2017-11-04 20:53:40 +00:00
|
|
|
},
|
2016-04-20 06:09:46 +00:00
|
|
|
externals: [
|
2016-10-02 20:57:00 +00:00
|
|
|
// Omit all dependencies in app/package.json (we want them loaded at runtime via NodeJS)
|
2018-10-17 16:42:33 +00:00
|
|
|
...Object.keys(pkg.dependencies).filter(name => !pkg.packedDependencies.includes(name)),
|
2017-01-27 01:00:27 +00:00
|
|
|
|
|
|
|
// To get jsonlint working...
|
2018-06-25 17:42:50 +00:00
|
|
|
'file',
|
2018-12-12 17:36:11 +00:00
|
|
|
'system',
|
2017-11-27 02:30:26 +00:00
|
|
|
],
|
2020-01-06 20:51:52 +00:00
|
|
|
plugins: [
|
2021-05-12 06:35:00 +00:00
|
|
|
new optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
|
|
|
|
new DefinePlugin({
|
2020-05-28 17:09:51 +00:00
|
|
|
'process.env.RELEASE_DATE': JSON.stringify(new Date()),
|
2020-01-06 20:51:52 +00:00
|
|
|
}),
|
2021-09-02 21:15:52 +00:00
|
|
|
// see: https://github.com/Kong/insomnia/pull/3469 for why this transform is needed
|
|
|
|
new NormalModuleReplacementPlugin(
|
|
|
|
/node_modules\/vscode-languageserver-types\/lib\/umd\/main\.js/,
|
|
|
|
'../esm/main.js',
|
|
|
|
),
|
2020-01-06 20:51:52 +00:00
|
|
|
],
|
2018-12-12 17:36:11 +00:00
|
|
|
target: 'electron-renderer',
|
2016-03-16 20:02:47 +00:00
|
|
|
};
|
2021-05-12 06:35:00 +00:00
|
|
|
|
|
|
|
export default configuration;
|