-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
50 lines (49 loc) · 1.88 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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
entry: './app/ts/loader.ts', // Assuming your TypeScript entry is named index.ts
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js', // Output bundle file name
},
module: {
rules: [
{
test: /\.tsx?$/, // Match TypeScript files
use: 'ts-loader', // Use ts-loader to transpile TypeScript
exclude: /node_modules/,
},
{
test: /\.css$/, // Match CSS files
use: ['style-loader', 'css-loader'], // Use loaders to handle CSS files
},
{
test: /\.(png|html)$/, // Match PNG and HTML files
type: 'asset/resource', // Emit a separate file and export the URL
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'], // Resolve extensions
},
mode: 'production', // Production mode to enable optimizations
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
'**/*', // This pattern indicates that all files will be cleaned...
'!**/.git', // Exclude the .git directory itself
'!**/.git/**', // Exclude all files within the .git directory
],
}),
new CopyPlugin({
patterns: [
{ from: 'app/index.html', to: 'index.html' },
{ from: 'app/cog.png', to: 'cog.png' },
{ from: 'app/app.css', to: 'app.css' },
{ from: 'node_modules/primeflex/primeflex.css', to: 'primeflex.css' },
{ from: 'node_modules/primeflex/themes/primeone-light.css', to: 'primeone-light.css' },
],
}),
],
};