forked from cc-archive/ccsearch-browser-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
80 lines (78 loc) · 1.97 KB
/
webpack.config.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
if (!process.env.TARGET) {
throw Error("Please specify env var TARGET, 'chrome', 'firefox' or 'opera'.");
} else if (!(process.env.TARGET === 'chrome' || process.env.TARGET === 'firefox' || process.env.TARGET === 'opera')) {
throw Error("TARGET can only be 'chrome', 'firefox' or 'opera'.");
} else {
console.info(`\x1b[1;32mBuilding for ${process.env.TARGET}...\x1b[m`);
}
module.exports = {
context: path.resolve(__dirname, 'src'),
devtool: 'cheap-module-source-map',
entry: {
'./popup/popup': './popup/popup.js',
'./options/options': './options/options.js',
},
output: {
path: path.resolve(__dirname, 'dist', process.env.TARGET),
filename: '[name].js',
},
node: {
global: false,
},
plugins: [
new CopyPlugin([
{
from: `./manifest.${process.env.TARGET}.json`,
to: './manifest.json',
},
{
from: './icons/*',
to: './icons',
flatten: true,
},
{
from: './options/*',
to: './options/',
flatten: true,
ignore: ['*.js'],
},
{
from: './popup/*',
to: './popup/',
flatten: true,
ignore: ['*.js'],
},
{
from: './popup/vendors/css/*',
to: './popup/vendors/css/',
flatten: true,
},
{
from: './popup/vendors/js/*',
to: './popup/vendors/js/',
flatten: true,
},
{
from: './popup/img/*',
to: './popup/img/',
flatten: true,
},
{
from: './popup/img/license_logos/*',
to: './popup/img/license_logos/',
flatten: true,
},
{
from: './popup/img/source_logos/*',
to: './popup/img/source_logos/',
flatten: true,
},
]),
new webpack.DefinePlugin({
global: 'window', // Placeholder for global used in any node_modules
}),
],
};