Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

61 righe
1.6 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: [
  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. };