aboutsummaryrefslogtreecommitdiff
path: root/pw_ide/ts/pigweed-vscode/webpack.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'pw_ide/ts/pigweed-vscode/webpack.config.js')
-rw-r--r--pw_ide/ts/pigweed-vscode/webpack.config.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/pw_ide/ts/pigweed-vscode/webpack.config.js b/pw_ide/ts/pigweed-vscode/webpack.config.js
new file mode 100644
index 000000000..df60d43f5
--- /dev/null
+++ b/pw_ide/ts/pigweed-vscode/webpack.config.js
@@ -0,0 +1,72 @@
+// Copyright 2023 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+'use strict';
+
+const path = require('path');
+const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
+const webpack = require('webpack');
+
+/**@type {import('webpack').Configuration}*/
+const config = {
+ // vscode extensions run in webworker context for VS
+ // Code web 📖 -> https://webpack.js.org/configuration/target/#target
+ target: 'webworker',
+
+ // the entry point of this extension, 📖 ->
+ // https://webpack.js.org/configuration/entry-context/
+ entry: './src/extension.ts',
+
+ output: {
+ // the bundle is stored in the 'dist' folder (check package.json), 📖 ->
+ // https://webpack.js.org/configuration/output/
+ path: path.resolve(__dirname, 'dist'),
+ filename: 'extension.js',
+ libraryTarget: 'commonjs2',
+ devtoolModuleFilenameTemplate: '../[resource-path]',
+ },
+ devtool: 'source-map',
+ plugins: [new NodePolyfillPlugin()],
+ externals: {
+ // the vscode-module is created on-the-fly and must
+ // be excluded. Add other modules that cannot be
+ // webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
+ vscode: 'commonjs vscode',
+ },
+ resolve: {
+ // support reading TypeScript and JavaScript files, 📖 ->
+ // https://github.com/TypeStrong/ts-loader
+ // look for `browser` entry point in imported node modules
+ mainFields: ['browser', 'module', 'main'],
+ extensions: ['.ts', '.js'],
+ alias: {
+ // provides alternate implementation for node module and source files
+ },
+ fallback: {
+ // 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.
+ },
+ },
+ module: {
+ rules: [
+ {
+ test: /\.ts$/,
+ exclude: /node_modules/,
+ use: [{ loader: 'ts-loader' }],
+ },
+ ],
+ },
+};
+module.exports = config;