This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
executable file
·77 lines (76 loc) · 1.95 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
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
const { manifestTransform } = require("./scripts/transform");
module.exports = (env, options) => {
return {
entry: {
content_script: "./src/content-scripts/index.js",
background: "./src/background.js",
popup: "./src/popup-page/index.js",
option: "./src/option-page/index.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
"file-loader",
{
loader: "image-webpack-loader",
options: {
bypassOnDebug: true, // webpack@1.x
disable: true // webpack@2.x and newer
}
}
]
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx", ".json"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "[name].bundle.js"
},
devtool: "inline-sourcemap",
plugins: [
new CopyWebpackPlugin(
[
{ from: "./src/popup-page/popup.html", force: true },
{ from: "./src/option-page/option.html", force: true },
{ from: "./src/app/", force: true }
],
{}
),
new webpack.DefinePlugin({
"process.env": dotenv.parsed
}),
new CopyWebpackPlugin([
{
from: "./src/app/manifest.json",
force: true,
transform(content, path) {
return manifestTransform(content, path, options);
}
}
]),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
contentBase: "./dist",
hot: true
}
};
};