Files
BrowserOS/packages/browseros-agent/apps/controller-ext/webpack.config.js
Dani Akash 290ee91a8b Add 'packages/browseros-agent/' from commit '90bd4be3008285bf3825aad3702aff98f872671a'
git-subtree-dir: packages/browseros-agent
git-subtree-mainline: 8f148d0918
git-subtree-split: 90bd4be300
2026-03-13 21:22:09 +05:30

84 lines
2.0 KiB
JavaScript

const path = require('node:path')
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
module.exports = (_env, argv) => {
const isProduction = argv.mode === 'production'
return {
mode: isProduction ? 'production' : 'development',
entry: {
background: './src/background/index.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
clean: true,
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: 'ts-loader',
options: {
onlyCompileBundledFiles: true,
compilerOptions: {
declaration: false,
declarationMap: false,
},
},
},
exclude: [/node_modules/, /\.(test|spec)\.(ts|tsx)$/],
},
],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new CopyPlugin({
patterns: [
{ from: 'manifest.json', to: '.' },
{ from: 'assets', to: 'assets' },
],
}),
],
devtool: isProduction ? false : 'source-map',
optimization: {
splitChunks: false,
runtimeChunk: false,
minimize: isProduction,
minimizer: isProduction
? [
new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
},
compress: {
// FIXME: nikhil - remove this later after few releases
drop_console: false,
drop_debugger: true,
},
},
}),
]
: [],
},
performance: {
hints: isProduction ? 'warning' : false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
}
}