-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
64 lines (63 loc) · 2.29 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
const path = require('path');
module.exports = {
entry: './src/DBPF.ts', // Entry point for your application
externals: {
"proper-lockfile": "lockfile"
},
output: {
filename: 'dbpf.web.js', // Output bundle file
path: path.resolve(__dirname, 'dist'), // Output directory
libraryTarget: 'umd', // Bundle for Node.js and the browser
globalObject: 'globalThis', // Fix global object in the browser
},
resolve: {
extensions: ['.ts', '.js', '.json'], // Resolve these extensions
alias: {
'@': path.resolve(__dirname, 'src'), // Example alias for imports
},
fallback: {
"fs": path.resolve(__dirname, "./src/polyfills/js/fs.js"),
"path": path.resolve(__dirname, "./src/polyfills/js/path.js"),
"buffer": require.resolve("buffer/"),
"worker_threads": path.resolve(__dirname, "./src/polyfills/js/worker_threads.js"),
}
},
module: {
rules: [
{
test: /src[\/\\].+.ts$/, // Source Files
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.esm.json', // Use this tsconfig file
}
}
], // Use ts-loader to transpile TypeScript
exclude: [
/node_modules/ // Exclude node_modules from transpilation
],
},
{
test: /test[\/\\].+.ts$/, // Test Files
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.test.json', // Use this tsconfig file
}
}
], // Use ts-loader to transpile TypeScript
exclude: [
/node_modules/ // Exclude node_modules from transpilation
],
},
{
test: /\.json$/, // Handle JSON imports
type: 'json',
},
],
},
devtool: false, // Disable source maps to match your tsconfig
mode: 'development', // Can be 'development' or 'production'
};