generated from vivid-lapin/ts
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack-loaders.ts
76 lines (71 loc) · 1.71 KB
/
webpack-loaders.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 MiniCSSExtractPlugin from "mini-css-extract-plugin"
import webpack from "webpack"
export const babelLoaderConfiguration: (b: boolean) => webpack.RuleSetRule = (
isDev
) => ({
test: [/\.tsx?$/, /\.ts$/, /\.js$/],
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [
["@babel/preset-env", { targets: { electron: "19" } }],
"@babel/preset-typescript",
[
"@babel/preset-react",
{
runtime: "automatic",
development: isDev,
importSource: "@welldone-software/why-did-you-render",
},
],
],
plugins: [
isDev && "react-refresh/babel",
"@babel/plugin-transform-runtime",
["@babel/plugin-transform-typescript", { isTSX: true }],
"@babel/plugin-transform-react-jsx",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-modules-commonjs",
].filter((s) => s),
},
},
})
export const nodeConfiguration: webpack.RuleSetRule = {
test: /\.node$/,
loader: "node-loader",
}
export const scssConfiguration: webpack.RuleSetRule = {
test: /\.s?css$/,
use: [
{
loader: MiniCSSExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader",
},
],
}
export const imageLoaderConfiguration: webpack.RuleSetRule = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: "url-loader",
options: {
name: "[name].[ext]",
esModule: false,
},
},
}
export const assetLoaderConfiguration: webpack.RuleSetRule = {
test: /\.(ttf)$/,
type: "asset/resource",
}