-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
57 lines (54 loc) · 1.44 KB
/
webpack.config.js
File metadata and controls
57 lines (54 loc) · 1.44 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
// webpack.config.js
const path = require('path');
const fs = require('fs');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = (env, argv) => {
// Determine which browser we're building for
const targetBrowser = env.browser || 'firefox';
const manifestPath = path.join(__dirname, `manifests/${targetBrowser}.json`);
// Ensure the manifest exists
if (!fs.existsSync(manifestPath)) {
throw new Error(`Manifest for ${targetBrowser} not found at ${manifestPath}`);
}
return {
mode: argv.mode || 'development',
entry: {
'background': './src/background.js',
'popup': './src/popup.js'
},
output: {
path: path.resolve(__dirname, 'dist', targetBrowser),
filename: '[name].js',
clean: true
},
plugins: [
new CopyPlugin({
patterns: [
{
from: manifestPath,
to: 'manifest.json'
},
{
from: './src/popup.html',
to: 'popup.html'
},
{
from: './src/browser-polyfill.js',
to: 'browser-polyfill.js'
},
{
from: './src/icons',
to: 'icons'
},
{
from: './src/rules.json',
to: 'rules.json'
}
],
}),
],
optimization: {
minimize: argv.mode === 'production',
},
};
};