-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (63 loc) · 2.4 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
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path_resolver = require('path');
module.exports = env => {
const args = env || {};
const chrome = !!args.chr;
return {
// Need empty `entry` so Webpack doesn't try to compile a `main.js`.
entry: {
},
output: {
path: path_resolver.resolve(
__dirname,
chrome ? 'dist-chrome' : 'dist-mozilla'
)
},
mode: 'development',
// According to [this](https://github.com/webpack/webpack/issues/4899#issuecomment-609737316),
// setting `devtool: 'source-map'` is the way to prevent `eval` in the packed JS.
// We can't have `eval`, since it is not allowed in browser extensions.
// I'm using 'inline-source-map' instead because plain 'source-map' won't seem to show up in Chrome devtools.
devtool: 'inline-source-map',
plugins: [
new CopyWebpackPlugin({
patterns: [
{
context: "src",
from: "content.js",
to: "content.js"
},
{
context: "src",
from: "bg.js",
to: "bg.js"
},
{
context: "src",
from: "options.html",
to: "options.html"
},
{
context: "src",
from: "options.js",
to: "options.js"
},
{
context: "src",
from: chrome ? "manifest.chrome.json" : "manifest.mozilla.json",
to: "manifest.json",
transform: (content, path) => {
const manifest = JSON.parse(content.toString());
// Add version number from package.json to manifest.json, so we don't have to repeat ourselves.
manifest.version = require("./package.json").version;
return JSON.stringify(manifest, null, 2);
},
},
]
}),
],
performance: {
hints: false
},
};
};