-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
140 lines (138 loc) · 4.78 KB
/
webpack.config.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
// const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
// const HTMLInlineCSSWebpackPlugin = require('html-inline-css-webpack-plugin').default; // Require the plugin
module.exports = {
entry: "./src/index.tsx",
mode: process.env.NODE_ENV || "development",
resolve: {
extensions: ['.js', '.ts', '.tsx', '.css', '.jsx'],
modules: [
path.resolve(__dirname, "src"),
"node_modules"
],
fallback: {
'react/jsx-runtime': 'react/jsx-runtime.js',
'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
}
},
devServer: {
static: {
directory: path.join(__dirname, "src")
},
compress: false,
port: 3000
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.(scss|sass)$/,
// exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
],
},
{
test: /\.(css)$/,
// loader: "style-loader!css-loader",
use: [
"style-loader",
"css-loader"
]
},
// {
// test: /\.scss$/,
// use: [
// { loader: 'style-loader' },
// { loader: 'css-loader' },
// // CHANGE HERE
// {
// loader: 'resolve-url-loader',
// options: {
// root: '/', // considering all your images are placed in specified folder. Note: this is just a string that will get as prefix to image path
// includeRoot: true,
// absolute: true,
// },
// },
// {
// loader: 'sass-loader',
// options: {
// sourceMap: true,
// // sourceMapContents: false,
// },
// },
// ],
// },
{
test: /\.(jpg|jpeg|svg|gif|png|svg)$/,
use: "file-loader"
},
// {
// test: /\.(jpg|jpeg|svg|gif|png)$/,
// loader: "file-loader",
// options: {
// // name: '[path][name].[ext]',
// name(resourcePath, resourceQuery) {
// return `${resourcePath.split(__dirname + '/')[1]}`
// // if (process.env.NODE_ENV === 'development') {
// // return '[path][name].[ext]';
// // }
// // return '[contenthash].[ext]';
// },
// }
// },
// {
// test: /\.svg$/,
// use: [
// {
// loader: 'svg-url-loader',
// options: {
// limit: 10000,
// },
// },
// ],
// },
// {
// test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
// use: [
// {
// loader: 'file-loader',
// options: {
// name: '[name].[ext]',
// outputPath: 'fonts/'
// }
// }
// ]
// },
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
}
],
},
plugins: [
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin ({
favicon: path.resolve(__dirname, "public/favicon.ico"),
// filename: path.resolve(__dirname, "public/index.html"),
template: path.join(__dirname, "public", "index.html"),
manifest: path.resolve(__dirname, "public/manifest.json")
})
// new HtmlWebpackPlugin ({ // 2
// favicon: "./public/favicon.ico",
// filename: "./public/index.html",
// manifest: "./public/manifest.json"
// })
// new HtmlWebpackPlugin({ // 1
// template: path.join(__dirname, "public", "index.html"),
// }),
],
};