-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.dev.js
More file actions
66 lines (63 loc) · 2.07 KB
/
webpack.dev.js
File metadata and controls
66 lines (63 loc) · 2.07 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import Dotenv from "dotenv-webpack";
import { merge } from "webpack-merge";
import baseConfig from "./webpack.config.js";
import CopyPlugin from "copy-webpack-plugin";
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
import webpack from "webpack";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import CrxLoadScriptWebpackPlugin from "@cooby/crx-load-script-webpack-plugin";
const __dirname = dirname(fileURLToPath(import.meta.url));
/** @returns {webpack.Configuration} */
const config = (env) => {
return {
mode: "development",
devtool: "inline-source-map",
entry: {
content: resolve(__dirname, "src", "pages", "content", "content.tsx"),
background: resolve(__dirname, "src", "pages", "background", "background.ts"),
},
devServer: {
static: {
watch: false,
},
client: {
webSocketURL: "ws://localhost:8080/ws",
},
devMiddleware: {
writeToDisk: true, // writes all output files to disk
},
allowedHosts: "all",
hot: false,
liveReload: false,
compress: true,
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ReactRefreshWebpackPlugin({ overlay: false }),
new CrxLoadScriptWebpackPlugin(),
new Dotenv({
path: "./.env.development",
}),
new CopyPlugin({
patterns: [
{ from: "src/assets", to: "assets" },
{
transform(content) {
const data = JSON.parse(content.toString());
data.name = "42FM - Dev";
data.action.default_icon["32"] = "assets/logo-32-dev.png";
data.icons["32"] = "assets/logo-32-dev.png";
data.icons["64"] = "assets/logo-64-dev.png";
data.icons["128"] = "assets/logo-128-dev.png";
return JSON.stringify(data, null, 2);
},
from: `public/manifest.${env.BROWSER}.json`,
to: "manifest.json",
},
],
}),
],
};
};
export default (env) => merge(baseConfig(env), config(env));