-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
69 lines (66 loc) · 1.72 KB
/
Copy pathwebpack.config.js
File metadata and controls
69 lines (66 loc) · 1.72 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
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
const prod = process.env.NODE_ENV === 'production';
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: prod ? 'production' : 'development',
entry: './src/index.tsx',
output: {
path: __dirname + '/dist/'
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
'@pages': path.resolve(__dirname, 'src/pages'),
'@components': path.resolve(__dirname, 'src/components'),
'@styles': path.resolve(__dirname, '/src/styles'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@assets': path.resolve(__dirname, 'src/assets'),
'@mocks': path.resolve(__dirname, 'src/mocks'),
'@entities': path.resolve(__dirname, 'src/entities')
}
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader'
}
]
},
{
test: /\.(ts|tsx)/,
exclude: /node_modules/,
use: 'ts-loader'
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack']
}
]
},
devtool: prod ? undefined : 'source-map',
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'index.html')
}),
new MiniCssExtractPlugin()
],
devServer: {
static: {
directory: path.join(__dirname, 'build'),
publicPath: '/'
},
port: 3000,
historyApiFallback: true
}
};