Notes/webpack.config.ts

79 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-07-23 00:12:08 +03:00
import { fileURLToPath } from "url";
import path from "path";
import autoprefixer from "autoprefixer";
import assetPath from "./src/services/asset_path.js";
import miniCssExtractPlugin from "mini-css-extract-plugin";
import type { Configuration } from "webpack";
2020-04-12 14:22:51 +02:00
2024-07-23 00:12:08 +03:00
const rootDir = path.dirname(fileURLToPath(import.meta.url));
const config: Configuration = {
2025-01-09 18:07:02 +02:00
mode: "production",
2020-04-12 14:22:51 +02:00
entry: {
2025-01-09 18:07:02 +02:00
setup: "./src/public/app/setup.js",
mobile: "./src/public/app/mobile.js",
desktop: "./src/public/app/desktop.js",
share: "./src/public/app/share.js",
// TriliumNextTODO: integrate set_password into setup entry point/view
set_password: "./src/public/app/set_password.js"
2020-04-12 14:22:51 +02:00
},
output: {
publicPath: `${assetPath}/app-dist/`,
2025-01-09 18:07:02 +02:00
path: path.resolve(rootDir, "src/public/app-dist"),
filename: "[name].js"
2020-04-12 14:22:51 +02:00
},
plugins: [
new miniCssExtractPlugin()
],
module: {
rules: [
{
2025-01-09 18:07:02 +02:00
test: /\.ts$/,
use: [
{
loader: "ts-loader",
options: {
configFile: path.join(rootDir, "tsconfig.webpack.json")
}
}
],
exclude: /node_modules/
},
{
// bootstrap CSS related configuration
test: /\.(scss)$/,
use: [
{
loader: miniCssExtractPlugin.loader
},
{
loader: "css-loader"
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [autoprefixer]
}
}
},
{
loader: "sass-loader"
}
]
2025-01-09 18:07:02 +02:00
}
]
},
resolve: {
2025-01-09 18:07:02 +02:00
extensions: [".ts", ".js"],
extensionAlias: {
".js": [".js", ".ts"],
".cjs": [".cjs", ".cts"],
".mjs": [".mjs", ".mts"]
}
},
//devtool: "none",
2025-01-09 18:07:02 +02:00
target: "electron-renderer"
2021-12-23 23:01:25 +01:00
};
export default config;