-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.dev.js
84 lines (82 loc) · 2.08 KB
/
webpack.config.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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const SpriteLoaderPlugin = require("svg-sprite-loader/plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const port = 3000;
module.exports = {
mode: "development",
devtool: "inline-source-map",
entry: path.resolve(__dirname, "./src/index.tsx"),
output: {
path: path.join(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/",
},
plugins: [
new MiniCssExtractPlugin(),
new Dotenv(),
new SpriteLoaderPlugin(),
new HtmlWebpackPlugin({
template: "public/index.html",
favicon: "public/favicon.ico",
}),
],
devServer: {
hot: true,
port: port || 3000,
open: true,
// page will likely have to be served in place of any 404 responses.
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: "ts-loader",
},
{
test: /\.(sass|scss)$/,
use: [
// "style-loader" // added styles to the head of index.html
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
],
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|webp|gif)$/,
exclude: /icons/,
type: "asset/resource",
},
{
test: /\.svg$/,
include: path.join(__dirname, "./src/icons"),
use: [
{
loader: "svg-sprite-loader",
options: {
spriteFilename: () => "sprite.svg",
symbolId: (filePath) => path.basename(filePath),
},
},
],
},
],
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: ["*", ".ts", ".tsx", ".js", ".png"],
},
};