-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
58 lines (55 loc) · 1.53 KB
/
webpack.config.ts
File metadata and controls
58 lines (55 loc) · 1.53 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
import path from 'path';
import HTMLWebpackPlugin from 'html-webpack-plugin';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import type { Configuration as ConfigurationWebpack } from 'webpack';
import type { Configuration as ConfigurationDevServer } from 'webpack-dev-server';
interface Configuration extends ConfigurationWebpack {
devServer?: ConfigurationDevServer
}
function configuration(_env: unknown, argv: { mode: string }): Configuration {
return {
entry: './src/index.tsx',
devtool: argv.mode === 'production' ? false : 'inline-source-map',
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(css|scss)$/,
use: ['style-loader', 'css-loader'],
exclude: /node_modules/,
},
{
test: /\.(jpg|jpeg|png|gif|mp3|svg)$/,
use: ['file-loader'],
exclude: /node_modules/,
},
],
},
plugins: [
new HTMLWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.html'),
}),
],
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
static: {
directory: path.resolve(__dirname, 'dist'),
},
historyApiFallback: true,
port: 8888,
open: false,
},
};
}
export default configuration;