Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

59 rader
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 minify = !!env.production;
  11. const sourceMaps = !env.production;
  12. const plugins = [
  13. new webpack.optimize.ModuleConcatenationPlugin(),
  14. new UglifyJsPlugin({
  15. parallel: true,
  16. sourceMap: sourceMaps,
  17. uglifyOptions: {
  18. ecma: 8,
  19. compress: minify ? {} : false,
  20. mangle: minify,
  21. output: {
  22. beautify: !minify,
  23. comments: false
  24. },
  25. sourceMap: sourceMaps,
  26. }
  27. })
  28. ];
  29. return {
  30. entry: './src/extension.ts',
  31. target: 'node',
  32. output: {
  33. libraryTarget: 'commonjs2',
  34. filename: 'extension.js',
  35. path: path.resolve(__dirname, 'out')
  36. },
  37. resolve: {
  38. extensions: ['.ts']
  39. },
  40. externals: [
  41. nodeExternals()
  42. ],
  43. devtool: sourceMaps ? 'inline-source-map' : false,
  44. module: {
  45. rules: [
  46. {
  47. test: /\.ts$/,
  48. use: [{ loader: 'ts-loader' }],
  49. exclude: /node_modules/
  50. }
  51. ]
  52. },
  53. plugins: plugins
  54. };
  55. };