-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
48 lines (45 loc) · 1.25 KB
/
webpack.prod.js
File metadata and controls
48 lines (45 loc) · 1.25 KB
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
import CopyPlugin from "copy-webpack-plugin";
import Dotenv from "dotenv-webpack";
import { dirname, resolve } from "path";
import TerserPlugin from "terser-webpack-plugin";
import { fileURLToPath } from "url";
import { merge } from "webpack-merge";
import baseConfig from "./webpack.config.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
/** @returns {webpack.Configuration} */
const config = (env) => {
return {
mode: "production",
entry: {
content: resolve(__dirname, "src", "pages", "content", "content.tsx"),
background: resolve(__dirname, "src", "pages", "background", "background.ts"),
iframe: resolve(__dirname, "src", "iframe.ts"),
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
minify: TerserPlugin.swcMinify,
}),
],
},
output: {
clean: true,
},
plugins: [
new Dotenv({
path: "./.env.production",
}),
new CopyPlugin({
patterns: [
{ from: "src/assets", to: "assets" },
{
from: `public/manifest.${env.BROWSER}.json`,
to: "manifest.json",
},
],
}),
],
};
};
export default (env) => merge(baseConfig(env), config(env));