-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
105 lines (102 loc) · 3.54 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
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const htmlPlugin = new HtmlWebpackPlugin({
template: "./public/index.html",
filename: "./index.html"
});
const CopyPlugin = require("copy-webpack-plugin");
module.exports = (_, argv) => {
return {
mode: argv.mode,
entry: path.resolve(__dirname, './src/index.jsx'),
optimization: {
// We no not want to minimize our code.
minimize: false
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpe?g|gif|json)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 10000,
},
},
],
},
// patching https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
},
{
test: /\.json$/i,
loader: 'json5-loader',
type: 'javascript/auto',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
devtool: 'inline-source-map',
plugins: [
new CleanWebpackPlugin(),
htmlPlugin,
// copying needed files from public folder
new CopyPlugin({
patterns: [
{ from: "./public/manifest.json", to: "./" },
{ from: "./public/facet_logo_512x512.png", to: "./" },
{ from: "./public/popup.html", to: "./" },
{ from: "./public/authentication.html", to: "./" },
{ from: "./public/welcome.html", to: "./" },
{ from: "./public/background.js", to: "./" },
{ from: "./public/mutationObserverVariableInjection.js", to: "./" },
{ from: "./public/preview-click-content.js", to: "./" },
{ from: "./public/facet-mutation-observer.js", to: "./" },
],
}),
// fix "process is not defined" error: https://stackoverflow.com/a/64553486/1373465
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
output: {
publicPath: '',
path: path.resolve(__dirname, './build'),
filename: 'bundle.js',
},
devServer: {
contentBase: path.resolve(__dirname, './build'),
hot: true
},
};
}