This repository was archived by the owner on Mar 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpackfile.client-dev.js
More file actions
110 lines (106 loc) · 2.52 KB
/
webpackfile.client-dev.js
File metadata and controls
110 lines (106 loc) · 2.52 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const { resolve } = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackRootPlugin = require('html-webpack-root-plugin');
const TSConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const publicPath = '/courses';
const {
APP_NAME,
CLIENT_PORT,
SERVER_URL,
SERVER_PORT,
PUBLIC_CLIENT_URL,
APP_VERSION
} = process.env;
/**
* This webpack configuration handles hot-reloading of client code in
* development.
*
* To change the production configuration for webpack, see webpackfile.js
*/
module.exports = {
name: 'client',
target: 'web',
mode: 'development',
devtool: 'cheap-eval-source-map',
entry: [
'react-hot-loader/patch',
'./src/client/index.tsx',
],
devServer: {
// This will push everything to the index.html file, letting us handle
// routing via React Router
historyApiFallback: {
rewrites: [
{ from: /./, to: '/courses/index.html' },
],
},
// We need to open the server to everyone so we can reach it from outside
// the container
host: '0.0.0.0',
hot: true,
hotOnly: true,
port: CLIENT_PORT,
publicPath,
serveIndex: false,
disableHostCheck: true,
},
output: {
path: resolve(__dirname, 'build/static'),
filename: 'app.js',
publicPath,
},
module: {
rules: [
{
test: /\.(t|j)sx?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
plugins: ['react-hot-loader/babel'],
},
},
'ts-loader',
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets/',
},
},
],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.svg'],
alias: {
'react-dom': '@hot-loader/react-dom',
},
plugins: [
new TSConfigPathsPlugin(),
],
},
plugins: [
new HtmlWebpackPlugin({
title: APP_NAME,
}),
new HtmlWebpackRootPlugin(),
new webpack.DefinePlugin({
'process.env.SERVER_URL': JSON.stringify(SERVER_URL),
'process.env.PUBLIC_CLIENT_URL': JSON.stringify(PUBLIC_CLIENT_URL),
'process.env.APP_VERSION': JSON.stringify(APP_VERSION),
}),
],
};