webpack.config.js 1.9 KB

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