-
-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathwebpack.config.js
90 lines (88 loc) · 2.41 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CspHtmlWebpackPlugin = require("csp-html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
target: "web",
entry: ["./src/index.js"],
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/",
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
include: [path.resolve(__dirname, "src")],
use: {
loader: "babel-loader",
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/typescript",
],
},
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
},
},
{
test: /\.scss$/,
include: [path.resolve(__dirname, "src")],
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
resolve: {
extensions: [".scss"],
},
},
{
test: /\.css$/,
include: [path.resolve(__dirname, "src"), path.resolve(__dirname, "node_modules")],
use: [MiniCssExtractPlugin.loader, "css-loader"],
resolve: {
extensions: [".css"],
},
},
{
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif|)$/,
use: "url-loader",
},
],
},
plugins: [
new MiniCssExtractPlugin({}),
new HtmlWebpackPlugin({
// if using template, add <title>Swell</title> and delete line 59.
// template: path.resolve(__dirname, "index-csp.html"),
filename: "index.html",
title: "Swell",
cspPlugin: {
enabled: true,
policy: {
"base-uri": "'self'",
"object-src": "'none'",
"script-src": ["'self'"],
"style-src": ["'self'"],
},
hashEnabled: {
"script-src": true,
"style-src": true,
},
nonceEnabled: {
"script-src": true,
"style-src": true,
},
},
}),
new CspHtmlWebpackPlugin(),
// options here: https://github.com/webpack-contrib/webpack-bundle-analyzer
// set to true to display bundle breakdown
new BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: 'static'
}),
],
};