forked from Razviar/mtgap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.renderer.config.js
86 lines (83 loc) · 1.93 KB
/
webpack.renderer.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
const rules = require('./webpack.rules');
const plugins = require('./webpack.plugins');
const path = require('path');
const ROOT = path.resolve(__dirname);
const SRC = path.join(ROOT, 'src');
const NODE_MODULES = path.join(ROOT, 'node_modules');
const CspHtmlWebpackPlugin = require('csp-html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const nonce = Math.random().toString().substr(2);
rules.push(
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
attributes: {
nonce: nonce,
},
},
},
{loader: 'css-loader'},
],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
attributes: {
nonce: nonce,
},
},
},
],
}
);
module.exports = {
// Put your normal webpack config below here
devtool: 'source-map',
module: {
rules,
},
plugins: plugins,
resolve: {
alias: {
root: SRC,
},
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.woff', '.woff2', '.ttf', '.eot', '.svg'],
modules: [NODE_MODULES],
},
plugins: [
new CspHtmlWebpackPlugin(
{
'base-uri': "'self'",
'object-src': "'none'",
'script-src': ["'self'"],
'img-src': ["'self'", 'https://mtgarena.pro/', 'data:'],
'style-src': ["'self'", "'unsafe-inline'"],
},
{
enabled: true,
hashingMethod: 'sha256',
hashEnabled: {
'script-src': false,
'style-src': false,
},
nonceEnabled: {
'script-src': false,
'style-src': false,
},
}
),
new CopyPlugin({
patterns: [
{context: 'src/windows', from: '*.woff*', to: 'home_window'},
{context: 'src/windows', from: '*.woff*', to: 'overlay_window'},
],
}),
],
};