You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

  1. 'use strict';
  2. const webpack = require('webpack');
  3. const path = require('path');
  4. const nodeExternals = require('webpack-node-externals');
  5. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  6. module.exports = function(env, argv) {
  7. if (env === undefined) {
  8. env = {};
  9. }
  10. const production = !!env.production;
  11. const minify = production;
  12. const sourceMaps = !production;
  13. const plugins = [
  14. new webpack.optimize.ModuleConcatenationPlugin(),
  15. new UglifyJsPlugin({
  16. parallel: true,
  17. sourceMap: sourceMaps,
  18. uglifyOptions: {
  19. ecma: 8,
  20. compress: minify ? {} : false,
  21. mangle: minify,
  22. output: {
  23. beautify: !minify,
  24. comments: false
  25. }
  26. }
  27. })
  28. ];
  29. return {
  30. entry: './src/extension.ts',
  31. mode: production ? 'production' : 'development',
  32. target: 'node',
  33. output: {
  34. libraryTarget: 'commonjs2',
  35. filename: 'extension.js',
  36. path: path.resolve(__dirname, 'out')
  37. },
  38. resolve: {
  39. extensions: ['.ts']
  40. },
  41. externals: [nodeExternals()],
  42. devtool: sourceMaps ? 'eval-source-map' : undefined,
  43. module: {
  44. rules: [
  45. {
  46. test: /\.ts$/,
  47. use: [{ loader: 'ts-loader' }],
  48. exclude: /node_modules/
  49. }
  50. ]
  51. },
  52. plugins: plugins
  53. };
  54. };