Files
vscode-extension-samples/helloworld-web-sample/webpack.config.js

69 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-08-20 12:04:40 +02:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/
const path = require('path');
const webpack = require('webpack');
2021-10-25 23:23:45 +02:00
/** @type WebpackConfig */
const webExtensionConfig = {
2021-08-20 12:04:40 +02:00
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
target: 'webworker', // extensions run in a webworker context
entry: {
2021-09-15 23:30:24 +02:00
extension: './src/web/extension.ts', // source of the web extension main file
'test/suite/index': './src/web/test/suite/index.ts', // source of the web extension test runner
},
output: {
filename: '[name].js',
path: path.join(__dirname, './dist/web'),
libraryTarget: 'commonjs',
2021-08-20 12:04:40 +02:00
},
resolve: {
2021-08-26 15:26:34 +02:00
mainFields: ['browser', 'module', 'main'], // look for `browser` entry point in imported node modules
2021-08-20 12:04:40 +02:00
extensions: ['.ts', '.js'], // support ts-files and js-files
alias: {
2021-08-26 15:26:34 +02:00
// provides alternate implementation for node module and source files
2021-08-20 12:04:40 +02:00
},
fallback: {
2021-08-26 15:26:34 +02:00
// Webpack 5 no longer polyfills Node.js core modules automatically.
// see https://webpack.js.org/configuration/resolve/#resolvefallback
// for the list of Node.js core module polyfills.
assert: require.resolve('assert'),
},
2021-08-20 12:04:40 +02:00
},
module: {
2021-08-26 15:26:34 +02:00
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
2021-08-20 12:04:40 +02:00
},
plugins: [
new webpack.ProvidePlugin({
2021-08-26 15:26:34 +02:00
process: 'process/browser', // provide a shim for the global `process` variable
2021-08-20 12:04:40 +02:00
}),
],
externals: {
2021-08-26 15:26:34 +02:00
vscode: 'commonjs vscode', // ignored because it doesn't exist
2021-08-20 12:04:40 +02:00
},
performance: {
2021-08-26 15:26:34 +02:00
hints: false,
2021-08-20 12:04:40 +02:00
},
2021-08-26 15:26:34 +02:00
devtool: 'nosources-source-map', // create a source map that points to the original source file
2021-08-20 12:04:40 +02:00
};
2021-09-15 23:30:24 +02:00
module.exports = [webExtensionConfig];