-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwebpack.config.js
81 lines (77 loc) · 2.01 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
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const outputDirectory = "dist";
module.exports = {
entry: {
main: ["babel-polyfill", "./src/client/index.tsx"],
// worker: ['babel-polyfill', "./src/client/worker.js"]
},
devtool: "source-map",
output: {
path: path.join(__dirname, outputDirectory),
filename: "[name].js",
chunkFilename: "[name].bundle.js",
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
},
module: {
rules: [
{ test: /\.tsx?$/, use: "ts-loader" },
{
test: /\.jsx?$/,
use: ["babel-loader", "source-map-loader"],
exclude: /.*\/node_modules\/.*/,
},
{
test: /\.css$/,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: "url-loader?limit=100000",
},
],
},
resolve: {
extensions: ["*", ".js", ".jsx", ".tsx", ".ts"],
},
devServer: {
port: 3000,
host: "127.0.0.1",
open: true,
proxy: {
"/api": "http://localhost:8080",
},
},
plugins: [
new CleanWebpackPlugin([outputDirectory]),
new CopyPlugin({
patterns: [
{
from: "public",
globOptions: {
ignore: [
// Ignore all `html` files
"**/*.html",
],
},
},
],
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
chunks: ["main"],
favicon: "./public/favicon.ico",
}),
// This is needed because SimplePeer requires access to the process (https://github.com/feross/simple-peer/issues/767)
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
};