-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
61 lines (58 loc) · 1.75 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
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
// const webpack = require('webpack');
if (!process.env.TARGET) {
throw Error("Please specify env var TARGET, 'chrome' or 'firefox'.");
} else if (
!(process.env.TARGET === "chrome" || process.env.TARGET === "firefox")
) {
throw Error("TARGET can only be 'chrome' or 'firefox'.");
} else {
console.info(`\x1b[1;32mBuilding for target ${process.env.TARGET}...\x1b[m`);
}
let config = {
context: path.resolve(__dirname, "src"),
entry: {
options: "./ui/options.js",
popup: "./ui/popup.js",
"service-worker": "./content-script/service-worker.js",
},
output: {
path: path.resolve(__dirname, "build", process.env.TARGET),
filename: "[name].dist.js",
},
resolve: {
modules: [path.resolve(__dirname, "node_modules")],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: "./static/", to: "./" },
{ from: "../LICENSE", to: "./" },
{ from: "../_locales/", to: "./_locales" },
{
from: `./manifest.${process.env.TARGET}.json`,
to: `./manifest.json`,
},
{ from: "../src/lib/openlocationcode.js", to: "./vendor/" },
{
from: "../node_modules/open-location-code/LICENSE",
to: "./vendor/openlocationcode.license.txt",
},
{
from: "../node_modules/bootstrap/dist/css/bootstrap.min.css",
to: "./vendor/css",
},
{
from: "../node_modules/file-saver/dist/FileSaver.min.js",
to: "./vendor",
},
],
}),
/* new webpack.DefinePlugin({
'ENVIRONMENT': require(`./src/environment.${process.env.TARGET}.js`)
}) */
],
devtool: "source-map",
};
module.exports = config;