2021-05-12 18:33:26 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2021 OpenLens Authors
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
|
|
* the Software without restriction, including without limitation the rights to
|
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
* subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2020-06-30 14:35:16 +03:00
|
|
|
import path from "path";
|
|
|
|
import webpack from "webpack";
|
2020-12-02 12:22:10 +03:00
|
|
|
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
|
2021-04-21 16:59:59 +03:00
|
|
|
import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars";
|
2020-06-30 14:35:16 +03:00
|
|
|
import nodeExternals from "webpack-node-externals";
|
2020-09-08 15:44:34 +03:00
|
|
|
import ProgressBarPlugin from "progress-bar-webpack-plugin";
|
2020-12-02 12:22:10 +03:00
|
|
|
import * as vars from "./src/common/vars";
|
2020-06-30 14:35:16 +03:00
|
|
|
|
|
|
|
export default function (): webpack.Configuration {
|
2020-12-02 12:22:10 +03:00
|
|
|
console.info("WEBPACK:main", vars);
|
2020-12-02 14:09:47 +03:00
|
|
|
|
2020-06-30 14:35:16 +03:00
|
|
|
return {
|
|
|
|
context: __dirname,
|
|
|
|
target: "electron-main",
|
|
|
|
mode: isProduction ? "production" : "development",
|
|
|
|
devtool: isProduction ? "source-map" : "cheap-eval-source-map",
|
|
|
|
cache: isDevelopment,
|
|
|
|
entry: {
|
|
|
|
main: path.resolve(mainDir, "index.ts"),
|
|
|
|
},
|
|
|
|
output: {
|
2020-10-09 14:12:40 +03:00
|
|
|
libraryTarget: "global",
|
2020-08-20 08:53:07 +03:00
|
|
|
path: buildDir,
|
2020-06-30 14:35:16 +03:00
|
|
|
},
|
|
|
|
resolve: {
|
2020-12-02 12:22:10 +03:00
|
|
|
extensions: [".json", ".js", ".ts"]
|
2020-06-30 14:35:16 +03:00
|
|
|
},
|
|
|
|
externals: [
|
|
|
|
nodeExternals()
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
|
|
|
use: "node-loader"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: "ts-loader",
|
|
|
|
options: {
|
|
|
|
transpileOnly: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
2020-09-08 15:44:34 +03:00
|
|
|
new ProgressBarPlugin(),
|
2020-06-30 14:35:16 +03:00
|
|
|
new ForkTsCheckerPlugin(),
|
2020-11-09 16:04:41 +03:00
|
|
|
].filter(Boolean)
|
2020-12-02 12:22:10 +03:00
|
|
|
};
|
2020-06-30 14:35:16 +03:00
|
|
|
}
|