mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-13 23:53:25 +00:00
git-subtree-dir: packages/browseros-agent git-subtree-mainline:8f148d0918git-subtree-split:90bd4be300
84 lines
2.0 KiB
JavaScript
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,
|
|
},
|
|
}
|
|
}
|