|
| 1 | +// This file is mostly (or fully) copied from here: |
| 2 | +// https://code.visualstudio.com/api/working-with-extensions/bundling-extension#configure-webpack |
| 3 | + |
| 4 | +//@ts-check |
| 5 | + |
| 6 | +'use strict' |
| 7 | + |
| 8 | +const path = require('path') |
| 9 | +const webpack = require('webpack') |
| 10 | + |
| 11 | +/**@type {import('webpack').Configuration}*/ |
| 12 | +const config = { |
| 13 | + target: 'webworker', // vscode extensions run in webworker context for VS Code web 📖 -> https://webpack.js.org/configuration/target/#target |
| 14 | + |
| 15 | + entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ |
| 16 | + output: { |
| 17 | + // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ |
| 18 | + path: path.resolve(__dirname, 'dist'), |
| 19 | + filename: 'extension.js', |
| 20 | + libraryTarget: 'commonjs2', |
| 21 | + devtoolModuleFilenameTemplate: '../[resource-path]' |
| 22 | + }, |
| 23 | + devtool: 'source-map', |
| 24 | + externals: { |
| 25 | + vscode: 'commonjs vscode' // 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/ |
| 26 | + }, |
| 27 | + resolve: { |
| 28 | + // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader |
| 29 | + mainFields: ['browser', 'module', 'main'], // look for `browser` entry point in imported node modules |
| 30 | + extensions: ['.ts', '.js'], // FIXME: Johan: Remove .js? We aren't doing any JavaScript. |
| 31 | + alias: { |
| 32 | + // provides alternate implementation for node module and source files |
| 33 | + }, |
| 34 | + fallback: { |
| 35 | + // Webpack 5 no longer polyfills Node.js core modules automatically. |
| 36 | + // see https://webpack.js.org/configuration/resolve/#resolvefallback |
| 37 | + // for the list of Node.js core module polyfills. |
| 38 | + } |
| 39 | + }, |
| 40 | + module: { |
| 41 | + rules: [ |
| 42 | + { |
| 43 | + test: /\.ts$/, |
| 44 | + exclude: /node_modules/, |
| 45 | + use: [ |
| 46 | + { |
| 47 | + loader: 'ts-loader' |
| 48 | + } |
| 49 | + ] |
| 50 | + } |
| 51 | + ] |
| 52 | + } |
| 53 | +} |
| 54 | +module.exports = config |
0 commit comments