forked from wtetsu/mouse-dictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (81 loc) · 2.38 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
81
82
83
84
85
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const UniteJsonPlugin = require("./build_tools/webpack_plugins/UniteJsonPlugin");
const jaRule = require("deinja/src/data");
const mode = process.env.NODE_ENV || "development";
const isProd = mode === "production";
const copyWebpackPluginConfigs = {
patterns: [
{ from: "static", to: "." },
{ from: __dirname + "/node_modules/milligram/dist/milligram.min.css", to: "options/" },
{ from: __dirname + "/node_modules/ace-builds/src-min-noconflict/worker-html.js", to: "options/" },
{ from: __dirname + "/node_modules/ace-builds/src-min-noconflict/worker-json.js", to: "options/" },
{ from: "static_pdf/options", to: "options/" },
],
};
if (!isProd) {
copyWebpackPluginConfigs.patterns.push({ from: "static_overwrite", to: "." });
}
module.exports = {
mode: mode,
entry: {
"options/options": "./src/options/app.tsx",
main: "./src/main/core/start.js",
background: "./src/background/background.js",
},
output: {
path: __dirname + "/dist",
},
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
use: {
loader: "babel-loader",
options: {
cacheDirectory: !isProd,
},
},
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".js", ".ts", ".tsx"],
},
plugins: [
new CopyPlugin(copyWebpackPluginConfigs),
new UniteJsonPlugin([
{
from: [
{ name: "letters", file: "rule/letters.json5" },
{ name: "noun", file: "rule/noun.json5" },
{ name: "phrase", file: "rule/phrase.json5" },
{ name: "pronoun", file: "rule/pronoun.json5" },
{ name: "spelling", file: "rule/spelling.json5" },
{ name: "trailing", file: "rule/trailing.json5" },
{ name: "verb", file: "rule/verb.json5" },
{ name: "ja", data: jaRule },
],
to: "data/rule.json",
},
]),
],
devtool: isProd ? false : "cheap-module-inline-source-map",
performance: {
maxEntrypointSize: 1000000,
maxAssetSize: 3000000,
},
optimization: {
minimize: isProd,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
pure_funcs: ["console.info", "console.warn", "console.time", "console.timeEnd"],
},
},
}),
],
},
};