-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack-app.config.js
75 lines (70 loc) · 1.65 KB
/
webpack-app.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
// webpack needs to be explicitly required
const webpack = require("webpack");
var path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const extractCss = new MiniCssExtractPlugin({
filename: "src/[name].css",
chunkFilename: "[id].css",
});
const html = new HtmlWebpackPlugin({
inject: true,
template: "index.html",
});
const staticFileRegex = /\.(woff|svg|ttf|eot|gif|jpeg|jpg|png|mp3)([\?]?.*)$/;
module.exports = {
entry: {
app: "./app/app.tsx",
},
output: {
filename: "src/[name].bundle.js",
path: path.resolve(__dirname, "build"),
publicPath: "/",
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js", ".scss", ".css"],
},
devServer: {
contentBase: path.resolve(__dirname, "build"),
port: 4568,
proxy: {
"/api": "http://localhost:4567",
"/static": "http://localhost:4567",
"/ws": {
target: "ws://localhost:4567",
ws: true,
},
},
publicPath: "/",
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: staticFileRegex,
include: [path.resolve(__dirname, "node_modules")],
type: "asset/resource",
},
],
},
plugins: [
extractCss,
html,
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
};