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.

60 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 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: 7,
  19. compress: minify,
  20. mangle: minify,
  21. output: {
  22. beautify: !minify,
  23. comments: false,
  24. ecma: 7
  25. },
  26. sourceMap: sourceMaps,
  27. }
  28. })
  29. ];
  30. return {
  31. entry: './src/extension.ts',
  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 ? 'inline-source-map' : false,
  45. module: {
  46. rules: [
  47. {
  48. test: /\.ts$/,
  49. use: 'ts-loader',
  50. exclude: /node_modules/
  51. }
  52. ]
  53. },
  54. plugins: plugins
  55. };
  56. };