-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
76 lines (72 loc) · 1.94 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
70
71
72
73
74
75
76
import CopyPlugin from 'copy-webpack-plugin';
import dotenv from 'dotenv';
import Dotenv from 'dotenv-webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import path from 'path';
import { Configuration } from 'webpack';
import 'webpack-dev-server';
import { isNullOrWhiteSpace } from './src/utils/strings';
const config = (env, argv): Configuration => {
dotenv.config({
path: `.env.${argv.mode}`,
});
const publicPath = isNullOrWhiteSpace({ str: process.env.BASE_PATH })
? '/'
: process.env.BASE_PATH;
return {
entry: './src/index.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
publicPath: publicPath === '/' ? publicPath : publicPath + '/',
},
devtool: 'inline-source-map',
module: {
rules: [
{ test: /\.ts$/, use: 'ts-loader', exclude: [/node_modules/, /tests/] },
{
test: /\.css$/i,
use: ['css-loader'],
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
plugins: [
new Dotenv({
path: `.env.${argv.mode}`,
}),
new HtmlWebpackPlugin({
title: 'Get It Done',
filename: 'index.html',
template: path.resolve(__dirname, 'src', 'assets', 'index.html'),
publicPath: publicPath,
}),
new HtmlWebpackPlugin({
title: 'Get It Done',
filename: '404.html',
template: path.resolve(__dirname, 'src', 'assets', '404.html'),
publicPath: publicPath,
}),
new CopyPlugin({
patterns: [
path.resolve(__dirname, 'src', 'assets', 'index.css'),
path.resolve(__dirname, 'src', 'assets', 'favicon.ico'),
],
}),
],
optimization: {
minimize: false,
},
devServer: {
static: {
directory: path.join(__dirname, 'src', 'assets'),
},
historyApiFallback: true,
port: 9000,
},
};
};
export default config;