Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/microsoft-authentication/extension.webpack.config.js
5243 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
// @ts-check
6
import withDefaults, { nodePlugins } from '../shared.webpack.config.mjs';
7
import CopyWebpackPlugin from 'copy-webpack-plugin';
8
import path from 'path';
9
10
const isWindows = process.platform === 'win32';
11
const isMacOS = process.platform === 'darwin';
12
const isLinux = !isWindows && !isMacOS;
13
14
const windowsArches = ['x64'];
15
const linuxArches = ['x64'];
16
17
let platformFolder;
18
switch (process.platform) {
19
case 'win32':
20
platformFolder = 'windows';
21
break;
22
case 'darwin':
23
platformFolder = 'macos';
24
break;
25
case 'linux':
26
platformFolder = 'linux';
27
break;
28
default:
29
throw new Error(`Unsupported platform: ${process.platform}`);
30
}
31
32
const arch = process.env.VSCODE_ARCH || process.arch;
33
console.log(`Building Microsoft Authentication Extension for ${process.platform} (${arch})`);
34
35
const plugins = [...nodePlugins(import.meta.dirname)];
36
if (
37
(isWindows && windowsArches.includes(arch)) ||
38
isMacOS ||
39
(isLinux && linuxArches.includes(arch))
40
) {
41
plugins.push(new CopyWebpackPlugin({
42
patterns: [
43
{
44
// The native files we need to ship with the extension
45
from: `**/dist/${platformFolder}/${arch}/(lib|)msal*.(node|dll|dylib|so)`,
46
to: '[name][ext]'
47
}
48
]
49
}));
50
}
51
52
export default withDefaults({
53
context: import.meta.dirname,
54
entry: {
55
extension: './src/extension.ts'
56
},
57
externals: {
58
// The @azure/msal-node-runtime package requires this native node module (.node).
59
// It is currently only included on Windows, but the package handles unsupported platforms
60
// gracefully.
61
'./msal-node-runtime': 'commonjs ./msal-node-runtime'
62
},
63
resolve: {
64
alias: {
65
'keytar': path.resolve(import.meta.dirname, 'packageMocks', 'keytar', 'index.js')
66
}
67
},
68
plugins
69
});
70
71