forked from signalapp/Signal-Desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
92 lines (87 loc) · 2.34 KB
/
webpack.config.ts
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
// Copyright 2019-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { resolve } from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import { Configuration, EnvironmentPlugin, ProvidePlugin } from 'webpack';
import HtmlWebpackPlugin = require('html-webpack-plugin');
const context = __dirname;
const { NODE_ENV: mode = 'development' } = process.env;
const isDev = mode === 'development';
const csp = `
default-src 'none';
child-src 'self';
connect-src 'self'${isDev ? ' http: ws:' : ''};
font-src 'self';
form-action 'self';
frame-src 'none';
img-src 'self' blob: data:;
media-src 'self' blob:;
object-src 'none';
script-src 'self'${isDev ? " 'unsafe-eval'" : ''};
style-src 'self' 'unsafe-inline';
`;
const stickerCreatorConfig: Configuration = {
context,
mode: mode as Configuration['mode'],
devtool: 'source-map',
entry: [
'react-hot-loader/patch',
'sanitize.css',
'typeface-inter',
'./sticker-creator/index.tsx',
],
output: {
path: resolve(context, 'sticker-creator/dist'),
filename: 'bundle.js',
publicPath: mode === 'production' ? './' : '/sticker-creator/dist/',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [{ loader: 'babel-loader' }],
},
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
{
test: /\.scss$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader?modules=true&localsConvention=camelCaseOnly' },
{ loader: 'sass-loader' },
],
},
{
test: /\.woff2?$/,
use: [{ loader: 'file-loader' }],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js'],
alias: {},
},
plugins: [
new ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
new EnvironmentPlugin(['NODE_ENV']),
new HtmlWebpackPlugin({
title: 'Signal Sticker Creator',
template: resolve(context, 'sticker-creator/index.html'),
meta: {
'Content-Security-Policy': {
'http-equiv': 'Content-Security-Policy',
content: csp,
},
},
}),
],
devServer: {
port: 6380,
historyApiFallback: {
rewrites: [{ from: /./, to: '/sticker-creator/dist/index.html' }],
},
},
};
export default [stickerCreatorConfig];