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