This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
59 lines (55 loc) · 1.51 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
const path = require("path");
const cp = require("child_process");
const CopyPlugin = require('copy-webpack-plugin');
const WebextensionPlugin = require('webpack-webextension-plugin');
const webpack = require('webpack');
const config = {
entry: {
content_script: path.join(__dirname, "src/content_script.tsx"),
},
output: {
filename: "[name].js",
path: path.join(__dirname, "dist"),
},
resolve: {
extensions: [".ts"],
},
module: {
rules: [
{ test: /\.tsx?$/, use: "ts-loader" },
]
},
optimization: {
minimize: false,
},
plugins: [
new CopyPlugin([
{ from: "**/*", context:"assets/" },
]),
new WebextensionPlugin({
vendor: "firefox",
}),
],
};
switch (process.env.NODE_ENV) {
case undefined:
case "production":
config.mode = "production";
config.devtool = "source-map";
break;
case "development":
config.mode = "development";
config.devtool = "eval-cheap-module-source-map";
config.plugins.push(new webpack.ProgressPlugin(function(percentage) {
if (percentage === 1) {
const result = cp.execSync("npx ts-node tests/parser_coverage.ts", {
encoding: "utf-8"
});
console.log(result);
}
}));
break;
default:
throw Error(`unkown NODE_ENV: "${process.env.NODE_ENV}"`)
}
module.exports = config;