forked from veiz/twitter-video-downloader-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (108 loc) · 2.68 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
99
100
101
102
103
104
105
106
107
108
109
110
111
const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const options = {
mode: process.env.NODE_ENV,
entry: {
content: [
path.resolve(__dirname, "src/content/index.js"),
path.resolve(__dirname, "src/content/index.scss"),
],
inject: path.resolve(__dirname, "src/inject.js"),
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
clean: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [
["@babel/preset-env", { useBuiltIns: "entry", corejs: 3 }],
],
plugins: [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-optional-chaining",
],
},
},
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader",
],
},
{
test: /\.html$/,
exclude: /node_modules/,
use: { loader: "html-loader" },
},
],
},
plugins: [
new webpack.ProgressPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.resolve(__dirname, "manifest.json"),
to: "manifest.json",
force: true,
transform: function (content) {
return Buffer.from(
JSON.stringify({
version: process.env.npm_package_version,
description: process.env.npm_package_description,
...JSON.parse(content.toString()),
})
);
},
},
{
from: path.resolve(__dirname, "public/icon-16.png"),
to: "icons",
},
{
from: path.resolve(__dirname, "public/icon-32.png"),
to: "icons",
},
{
from: path.resolve(__dirname, "public/icon-48.png"),
to: "icons",
},
{
from: path.resolve(__dirname, "public/icon-128.png"),
to: "icons",
},
],
}),
],
};
if (process.env.NODE_ENV === "development") {
options.devtool = "cheap-module-source-map";
} else {
options.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
],
};
}
module.exports = options;