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.

61 rivejä
1.6 KiB

6 vuotta sitten
6 vuotta sitten
  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: [
  42. nodeExternals()
  43. ],
  44. devtool: sourceMaps ? 'eval-source-map' : undefined,
  45. module: {
  46. rules: [
  47. {
  48. test: /\.ts$/,
  49. use: [{ loader: 'ts-loader' }],
  50. exclude: /node_modules/
  51. }
  52. ]
  53. },
  54. plugins: plugins
  55. };
  56. };