-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
69 lines (67 loc) · 1.67 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
import path from 'path';
import webpack from 'webpack';
import 'webpack-dev-server';
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config: webpack.Configuration = {
mode: 'development', // or 'production'
entry: './client/src/index.tsx',
devtool: 'inline-source-map',
plugins: [
new HtmlWebpackPlugin({
template: './client/public/index.html',
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader', // Injects CSS into the DOM
'css-loader', // Turns CSS into CommonJS
'postcss-loader', // Processes Tailwind and other PostCSS plugins
],
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
exclude: /node_modules/,
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images', // where the images will go under the output directory
publicPath: 'images', // path used to generate URLs to the images
name: '[name].[ext]', // retain original file names
},
},
],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
static: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
},
};
export default config;