-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.webview.config.js
53 lines (53 loc) · 1.59 KB
/
webpack.webview.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
const path = require('path');
const webpack = require('webpack');
module.exports = {
mode: 'development', // Use 'production' for production builds
entry: './src/webview/index.tsx', // Entry point for your app
output: {
path: path.resolve(__dirname, 'out'), // Output directory
filename: 'bundle.js', // Output bundle file
},
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/, // Handle .js, .jsx, .ts, and .tsx files
exclude: /node_modules|src\/test/, // Exclude dependencies
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env', // Transpile modern JavaScript (ES6+)
'@babel/preset-react', // Transpile JSX for React
'@babel/preset-typescript', // Transpile TypeScript
],
},
},
},
{
test: /\.scss$/,
use: [
'style-loader', // Injects styles into DOM
'css-loader', // Turns CSS into CommonJS
'sass-loader', // Compiles Sass to CSS
],
},
{
test: /\.(png|svg)$/, // Handle image files
use: ['file-loader'],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Automatically resolve these extensions
fallback: {
'process/browser': require.resolve('process/browser'), // Provide fallback for "process"
buffer: require.resolve('buffer/'),
},
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser', // Make "process" globally available
Buffer: ['buffer', 'Buffer'],
}),
],
};