-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
61 lines (55 loc) · 1.55 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
const path = require('path');
// Define loaders
// Loaders for processing Sass files
const sassLoaders = [
'style-loader', // Creates `style` nodes from JS strings
'css-loader', // Translates CSS into CommonJS
'sass-loader', // Compiles Sass to CSS
];
// Loaders for processing CSS files
const cssLoaders = ['style-loader', 'css-loader'];
// Loaders for processing image files
const imageLoaders = {
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]', // Keep the original file name and extension
},
};
// Loaders for processing font files
const fontLoaders = {
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
generator: {
filename: '[name][ext]', // Keep the original file name and extension
},
};
// Loaders for processing TypeScript files
const tsLoaders = {
test: /\.ts$/i,
use: 'ts-loader',
};
module.exports = {
mode: 'production', // Set build mode to production
entry: path.join(__dirname, 'src', 'index.ts'), // Specify entry point
module: {
rules: [
// Apply loaders
{ test: /\.s[ac]ss$/i, use: sassLoaders },
{ test: /\.css$/i, use: cssLoaders },
imageLoaders,
fontLoaders,
tsLoaders,
],
},
devtool: false, // Disable source maps
// devtool: 'source-map', // Generate source maps for easier debugging
resolve: {
extensions: ['.ts', '.js'], // Specify file extensions to resolve
},
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'assets'),
assetModuleFilename: '[name].[ext]',
},
};