-
Notifications
You must be signed in to change notification settings - Fork 95
/
webpack.config.js
executable file
·212 lines (207 loc) · 5.63 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//@ts-check
"use strict";
const WebpackShellPluginNext = require("webpack-shell-plugin-next");
const TerserPlugin = require("terser-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const path = require("path");
const { cpSync } = require("fs");
/**@type {import('webpack').Configuration}*/
const config = {
target: "node",
entry: path.resolve(__dirname, "src/extension.ts"),
output: {
path: path.resolve(__dirname, "dist"),
filename: "extension.js",
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
node: {
__dirname: false,
},
devtool: "source-map",
externals: [
"vscode",
"commonjs",
// These dependencies are ignored because we don't use them, and App Insights has try-catch protecting their loading if they don't exist
// See: https://github.com/microsoft/vscode-extension-telemetry/issues/41#issuecomment-598852991
"applicationinsights-native-metrics",
"@opentelemetry/tracing",
"@azure/opentelemetry-instrumentation-azure-sdk",
"@opentelemetry/instrumentation",
"@azure/functions-core",
"zeromq",
],
resolve: {
extensions: [".ts", ".js"],
alias: {
"@extension": path.resolve(__dirname, "./src/modules.ts"),
"@lib": path.resolve(__dirname, "./src/lib/index"),
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
},
],
},
],
},
plugins: [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "altimate_notebook_kernel.py"),
to: "altimate_notebook_kernel.py",
},
{
from: path.resolve(__dirname, "dbt_core_integration.py"),
to: "dbt_core_integration.py",
},
{
from: path.resolve(__dirname, "dbt_cloud_integration.py"),
to: "dbt_cloud_integration.py",
},
{
from: path.resolve(__dirname, "dbt_healthcheck.py"),
to: "dbt_healthcheck.py",
},
{
from: path.resolve(
__dirname,
"node_modules/python-bridge/node_python_bridge.py",
),
to: "node_python_bridge.py",
},
{
from: path.resolve(__dirname, "altimate_packages/"),
to: "altimate_packages/",
},
],
}),
new WebpackShellPluginNext({
onBuildStart: {
scripts: [
() => {
try {
console.log("copying notebook modules");
cpSync("./node_modules/zeromq", "./dist/node_modules/zeromq", {
recursive: true,
});
cpSync(
"./node_modules/@aminya/node-gyp-build",
"./dist/node_modules/@aminya/node-gyp-build",
{
recursive: true,
},
);
cpSync(
"./node_modules/node-gyp-build",
"./dist/node_modules/node-gyp-build",
{
recursive: true,
},
);
console.log("copied notebook modules");
} catch (error) {
console.error(error.message);
}
},
],
blocking: true,
parallel: false,
},
}),
],
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
mangle: false,
sourceMap: true,
// compress: false,
keep_classnames: /AbortSignal/,
keep_fnames: /AbortSignal/,
output: {
beautify: true,
indent_level: 1,
},
},
}),
],
},
};
const rendererConfig = {
devtool: "source-map",
target: ["web", "es5"],
externals: {
vscode: "commonjs vscode",
zeromq: "zeromq",
},
entry: "./webview_panels/src/notebook/index.tsx",
output: {
path: path.resolve(__dirname, "dist"),
filename: "renderer.js",
libraryTarget: "module",
},
resolve: {
extensions: [".ts", ".tsx", ".css"],
alias: {
"@uicore": path.resolve(__dirname, "./webview_panels/src/uiCore"),
"@assets": path.resolve(__dirname, "./webview_panels/src/assets"),
"@modules": path.resolve(__dirname, "./webview_panels/src/modules"),
"@testUtils": path.resolve(__dirname, "./webview_panels/src/testUtils"),
"@vscodeApi": path.resolve(
__dirname,
"./webview_panels/src/modules/vscode",
),
"@lib": path.resolve(__dirname, "./webview_panels/src/lib"),
},
},
experiments: {
outputModule: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
options: {
configFile: path.resolve(
__dirname,
"./webview_panels/tsconfig.json",
),
projectReferences: true,
compilerOptions: {
module: "esnext",
noEmit: false,
outDir: "../../out/src/renderer",
},
},
},
// {
// loader: "esbuild-loader",
// options: {
// loader: "tsx", // Remove this if you're not using JSX
// target: "es2015", // Syntax to compile to (see options below for possible values)
// },
// },
],
},
{
test: /\.css$/i,
use: ["raw-loader"],
},
],
},
};
module.exports = [config];