• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2023 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14
15'use strict';
16
17const path = require('path');
18const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
19const webpack = require('webpack');
20
21/**@type {import('webpack').Configuration}*/
22const config = {
23  // vscode extensions run in webworker context for VS
24  // Code web �� -> https://webpack.js.org/configuration/target/#target
25  target: 'webworker',
26
27  // the entry point of this extension, �� ->
28  // https://webpack.js.org/configuration/entry-context/
29  entry: './src/extension.ts',
30
31  output: {
32    // the bundle is stored in the 'dist' folder (check package.json), �� ->
33    // https://webpack.js.org/configuration/output/
34    path: path.resolve(__dirname, 'dist'),
35    filename: 'extension.js',
36    libraryTarget: 'commonjs2',
37    devtoolModuleFilenameTemplate: '../[resource-path]',
38  },
39  devtool: 'source-map',
40  plugins: [new NodePolyfillPlugin()],
41  externals: {
42    // the vscode-module is created on-the-fly and must
43    // be excluded. Add other modules that cannot be
44    // webpack'ed, �� -> https://webpack.js.org/configuration/externals/
45    vscode: 'commonjs vscode',
46  },
47  resolve: {
48    // support reading TypeScript and JavaScript files, �� ->
49    // https://github.com/TypeStrong/ts-loader
50    // look for `browser` entry point in imported node modules
51    mainFields: ['browser', 'module', 'main'],
52    extensions: ['.ts', '.js'],
53    alias: {
54      // provides alternate implementation for node module and source files
55    },
56    fallback: {
57      // Webpack 5 no longer polyfills Node.js core modules automatically.
58      // see https://webpack.js.org/configuration/resolve/#resolvefallback
59      // for the list of Node.js core module polyfills.
60    },
61  },
62  module: {
63    rules: [
64      {
65        test: /\.ts$/,
66        exclude: /node_modules/,
67        use: [{ loader: 'ts-loader' }],
68      },
69    ],
70  },
71};
72module.exports = config;
73