1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/webpack.main.ts
Sebastian Malton 9cbb842199 fix using this in a plain function
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
2020-09-01 12:59:20 -04:00

61 lines
1.5 KiB
TypeScript
Executable File

import path from "path";
import webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
import { isDevelopment, isProduction, mainDir, buildDir } from "./src/common/vars";
import nodeExternals from "webpack-node-externals";
import TerserPlugin from "terser-webpack-plugin";
export default function (): webpack.Configuration {
const res: webpack.Configuration = {
context: __dirname,
target: "electron-main",
mode: isProduction ? "production" : "development",
devtool: "source-map",
cache: isDevelopment,
entry: {
main: path.resolve(mainDir, "index.ts"),
},
output: {
path: buildDir,
},
resolve: {
extensions: ['.json', '.js', '.ts']
},
node: {
// webpack modifies node internals by default, keep as is for main-process
__dirname: false,
__filename: false,
},
externals: [
nodeExternals()
],
module: {
rules: [
{
test: /\.node$/,
use: "node-loader"
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
}
}
},
]
},
plugins: [
new ForkTsCheckerPlugin(),
],
optimization: {
minimize: isProduction,
minimizer: isProduction ? undefined : [new TerserPlugin()]
}
}
console.info('WEBPACK:main', res)
return res
}