-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (87 loc) · 2.56 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
86
87
88
89
90
91
92
93
94
95
96
97
98
const MiniCssExtractPlugin=require("mini-css-extract-plugin");
const ForkTsCheckerWebpackPlugin=require("fork-ts-checker-webpack-plugin");
const CopyPlugin=require("copy-webpack-plugin");
const WebpackBar=require("webpackbar");
// prod:boolean //enable production mode
module.exports=(env)=>{
env=env || {};
var mode=env.prod?"production":"development";
var outputPath=env.prod?"release":"build";
var jsOutput=env.prod?"build":".";
var cssOutput=env.prod?"build":".";
var devtool=env.prod?false:"cheap-module-source-map";
var plugins=[
new MiniCssExtractPlugin({
filename:`${cssOutput}/[name]-build.css`
}),
new ForkTsCheckerWebpackPlugin(),
new WebpackBar()
];
if (env.prod)
{
plugins.push(new CopyPlugin({
patterns:[
{
from:"assets",
to:"assets"
},
{
from:"popup/popup-index.html",
to:"popup"
},
{
from:"showlist/showlist-index.html",
to:"showlist"
},
{
from:"Manifest.json",
to:"."
}
]
}));
}
return {
mode,
entry:{
anilisthook:"./anilist-hooks/anilist-hook.ts",
showlist:"./showlist/showlist-index.tsx",
popup:"./popup/popup-index.tsx"
},
output:{
path:`${__dirname}/${outputPath}`,
filename:`${jsOutput}/[name]-build.js`
},
module:{
rules:[
{
test:/\.(tsx|ts|js|jsx)$/,
exclude:/node_modules/,
use:{
loader:"babel-loader",
options:{
presets:["@babel/preset-react","@babel/preset-typescript"]
}
}
},
{
test:/\.(less|css)$/,
use:[
MiniCssExtractPlugin.loader,
{loader:"css-loader",options:{url:false}},
{loader:"less-loader"}
]
}
]
},
plugins,
resolve:{
extensions:[".tsx",".ts",".jsx",".js"]
},
stats:{
entrypoints:false,
modules:false,
chunks:false
},
devtool
};
};