-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.webview.config.js
128 lines (120 loc) · 3.56 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const path = require('path');
//const fs = require('fs');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
// change to index.tsx
entry: './src/webview/index.tsx',
//entry: './src/webview/main.ts', // Entry point for the webview
// webview-dist / filename bundle.js
output: {
path: path.resolve(__dirname, 'dist/webview'),
filename: 'bundle.js',
// path: path.resolve(__dirname, 'dist'), // Output directory
// filename: 'webview.bundle.js', // Output file
},
resolve: {
extensions: ['.tsx', '.ts', '.js'], // Resolve TypeScript and JavaScript files
},
watch: true,
module: {
rules: [
{
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules/,
use: 'babel-loader', // Use Babel for React and TypeScript
},
{
test: /\.css$/, // Add this rule
use: ['style-loader', 'css-loader'], // Process CSS files
},
],
// rules: [
// {
// test: /\.ts$/,
// use: 'ts-loader',
// exclude: /node_modules/,
// },
// {
// test: /\.css$/,
// use: ['style-loader', 'css-loader'], // Load CSS files
// },
// ],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/webview/index.html', // Updated path for React webview
}),
// new HtmlWebpackPlugin({
// template: './src/webview/index.html', // HTML template for the webview
// filename: 'index.html',
// }),
],
// devServer: {
// static: {
// directory: path.resolve(__dirname, 'dist'), // Serve static files from dist
// },
// server: {
// type: 'http',
// },
// port: 3000, // Port for the dev server
// open: true, // Automatically open in the browser
// hot: true, // Enable Hot Module Replacement
// },
};
// the following has come up several times in https server/webpack setup
// might come in handy when we start working on dev and prod
// devServer: process.env.NODE_ENV === 'development' ? {
// https: {
// key: path.resolve(__dirname, 'certs/key.pem'),
// cert: path.resolve(__dirname, 'certs/cert.pem'),
// },
// port: 3000,
// } : undefined,
// OLD WEBPACK SETUP, LETS KEEP FOR NOW UNTIL CURRENT WEBPACK PROVES WORTHY!
// const path = require('path');
// const HtmlWebpackPlugin = require('html-webpack-plugin');
// module.exports = {
// mode: 'development',
// entry: './src/webview/main.ts', // Entry point for the webview
// output: {
// path: path.resolve(__dirname, 'dist'), // Output directory
// filename: 'webview.bundle.js', // Output file
// },
// resolve: {
// extensions: ['.ts', '.js'],
// },
// module: {
// rules: [
// {
// test: /\.ts$/,
// use: 'ts-loader',
// exclude: /node_modules/,
// },
// {
// test: /\.css$/,
// use: ['style-loader', 'css-loader'], // Load CSS
// },
// ],
// },
// plugins: [
// new HtmlWebpackPlugin({
// template: './src/webview/index.html', // Use your HTML file as a template
// filename: 'index.html',
// }),
// ],
// devServer: {
// static: {
// directory: path.resolve(__dirname, 'dist', 'webview'),
// },
// server: {
// type: 'https', // Specify HTTPS
// options: {
// key: path.resolve(__dirname, 'certs/localhost-key.pem'), // Path to SSL private key
// cert: path.resolve(__dirname, 'certs/localhost.pem'), // Path to SSL certificate
// },
// },
// port: 3000,
// open: true, // Automatically open in the browser
// },
// };