webpack.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // asyncWebAssembly: true,
  12. // syncWebAssembly: true,
  13. },
  14. entry: './src/main.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
  15. output: {
  16. // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
  17. path: path.resolve(__dirname, 'out'),
  18. filename: 'main.js',
  19. libraryTarget: 'commonjs2',
  20. devtoolModuleFilenameTemplate: '../[resource-path]',
  21. publicPath: '',
  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'],
  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. // "util": require.resolve("util/")
  39. }
  40. },
  41. module: {
  42. rules: [
  43. {
  44. test: /\.ts$/,
  45. exclude: /node_modules/,
  46. use: [
  47. {
  48. loader: 'ts-loader'
  49. }
  50. ]
  51. }
  52. // {
  53. // test: /\.wasm$/,
  54. // type: "asset/inline",
  55. // }
  56. ]
  57. },
  58. };
  59. module.exports = config;