1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/webpack.main.ts
Hung-Han (Henry) Chen 4e02f943f3
Correction of chuck name
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
2021-01-07 11:22:50 +08:00

74 lines
2.2 KiB
TypeScript
Executable File

import path from "path";
import webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { appName, isDevelopment, isProduction, mainDir, buildDir } from "./src/common/vars";
import nodeExternals from "webpack-node-externals";
import * as vars from "./src/common/vars";
export default function (): webpack.Configuration {
console.info("WEBPACK:main", vars);
return {
target: "electron-main",
mode: isProduction ? "production" : "development",
devtool: isProduction ? "source-map" : "eval-source-map",
cache: isDevelopment ? {
type: "filesystem",
buildDependencies: {
// Add your config as buildDependency to get cache invalidation on config change
config: [__filename]
}
}: false,
entry: {
main: path.resolve(mainDir, "index.ts"),
},
output: {
libraryTarget: "global",
path: buildDir,
},
resolve: {
extensions: [".json", ".js", ".ts"]
},
// in order to ignore built-in modules like path, fs, etc.
externalsPresets: { node: true },
// in order to ignore all modules in node_modules folder
externals: nodeExternals(),
optimization: {
minimize: isProduction,
// Automatically split vendor and commons in development
// (for faster re-compiling)
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
splitChunks: isDevelopment ? {
// chunks can be shared even between async and non-async chunks
chunks: "all",
name: `${appName}.main.chucks.js`
} : false,
runtimeChunk: isDevelopment ? {
name: `${appName}.main.chucks.runtime.js`,
} : false,
},
module: {
rules: [
{
test: /\.node$/,
use: "node-loader"
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
}
}
},
]
},
plugins: [
new ForkTsCheckerPlugin(),
new webpack.ProgressPlugin({ percentBy: "entries" }),
]
};
}