-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
58 lines (56 loc) · 1.54 KB
/
webpack.config.js
File metadata and controls
58 lines (56 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const isProduction = process.env.NODE_ENV === 'production';
const targetBrowser = process.env.TARGET_BROWSER || 'chrome'; // Default to Chrome, supports 'chrome' or 'firefox'
const distPath = path.resolve(__dirname, 'dist', targetBrowser);
module.exports = {
entry: {
index: './src/index.ts',
popup: './src/popup/popup.ts',
options: './src/options/options.ts',
},
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? false : 'source-map', // No source maps in production
output: {
path: distPath,
filename: '[name].js',
clean: true, // Clean dist folder before each build
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
}),
new CopyPlugin({
patterns: [
{ from: "src/popup/popup.html", to: "." },
{ from: "src/options/options.html", to: "." },
{ from: "icons", to: "icons" },
{
from: targetBrowser === 'chrome' ? 'manifest.chrome.json' : 'manifest.firefox.json',
to: 'manifest.json'
}
],
}),
],
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.json$/,
type: 'json',
},
],
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
};