-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathwebpack.dev.js
94 lines (93 loc) · 2.08 KB
/
webpack.dev.js
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
// webpack.dev.js (in project root)
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
entry: path.resolve(__dirname, 'src/dev/index.tsx'),
output: {
path: path.resolve(__dirname, 'dev-dist'),
publicPath: '/',
filename: 'bundle.js',
},
devServer: {
static: {
directory: path.join(__dirname, 'dev-dist'),
},
hot: true,
port: 3011,
open: true,
historyApiFallback: true,
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx', '.json'],
alias: {
'@telsho/react-google-flight-datepicker': path.resolve(__dirname, 'src'),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: 'ts-loader',
},
{
test: /\.svg$/,
oneOf: [
{
issuer: /\.[jt]sx?$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgo: false,
titleProp: true,
}
}
]
},
{
type: 'asset/resource',
generator: {
filename: 'static/media/[name].[hash][ext]'
}
}
]
},
{
test: /\.s?css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
templateContent: `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React Google Flight Datepicker</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
`,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
],
};