-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.utils.js
37 lines (33 loc) · 953 Bytes
/
webpack.utils.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
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const getOutput = (browserDir, outputDir = "dev") => {
return {
path: path.resolve(__dirname, `${outputDir}/${browserDir}`),
filename: "[name].js",
};
};
const getEntry = (sourceDir = "src") => {
return {
content: path.resolve(__dirname, `${sourceDir}/content.js`),
background: path.resolve(__dirname, `${sourceDir}/background.js`),
};
};
const getCopyPlugins = (browserDir, outputDir = "dev", sourceDir = "src") => [
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "./icons"),
to: path.resolve(__dirname, `${outputDir}/${browserDir}/icons`),
},
{
from: path.resolve(__dirname, "./manifest.json"),
to: path.resolve(__dirname, `${outputDir}/${browserDir}/manifest.json`),
},
],
}),
];
module.exports = {
getOutput,
getCopyPlugins,
getEntry,
};