browser-extension/webpack.config.js

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2025-06-22 14:20:38 +05:00
const path = require('path');
const { merge } = require('webpack-merge');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const common = require('./webpack.common.js');
const appConfig = {
2025-06-22 14:20:38 +05:00
entry: './src/index.tsx',
output: {
2025-06-22 14:20:38 +05:00
path: path.resolve(__dirname, 'build'),
filename: 'static/js/app.bundle.js',
},
plugins: [
new HtmlWebpackPlugin({
2025-06-22 14:20:38 +05:00
template: './public/index.html',
filename: 'index.html',
inject: 'body',
}),
],
};
const backgroundConfig = {
2025-06-22 14:20:38 +05:00
entry: './src/background/background.ts',
output: {
2025-06-22 14:20:38 +05:00
path: path.resolve(__dirname, 'build/static/js'),
filename: 'background.bundle.js',
},
};
const contentConfig = {
2025-06-22 14:20:38 +05:00
entry: './src/content/content.ts',
output: {
2025-06-22 14:20:38 +05:00
path: path.resolve(__dirname, 'build/static/js'),
filename: 'content.bundle.js',
},
};
2023-04-22 05:08:57 +04:00
const injectConfig = {
2025-06-22 14:20:38 +05:00
entry: './src/content/inject.ts',
2023-04-22 05:08:57 +04:00
output: {
2025-06-22 14:20:38 +05:00
path: path.resolve(__dirname, 'build/static/js'),
filename: 'inject.bundle.js',
2023-04-22 05:08:57 +04:00
},
};
const copyConfig = {
plugins: [
new CopyWebpackPlugin({
patterns: [
2025-06-22 14:20:38 +05:00
{ from: 'public/images', to: 'images' },
{ from: 'public/manifest.json', to: 'manifest.json' },
{ from: 'public/robots.txt', to: 'robots.txt' },
],
}),
],
};
2025-06-22 14:20:38 +05:00
module.exports = [merge(common, appConfig, copyConfig), merge(common, backgroundConfig), merge(common, contentConfig), merge(common, injectConfig)];