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.

62 lines
1.6 KiB

пре 7 година
  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. sourceMap: sourceMaps,
  27. }
  28. })
  29. ];
  30. return {
  31. entry: './src/extension.ts',
  32. mode: production ? 'production' : 'development',
  33. target: 'node',
  34. output: {
  35. libraryTarget: 'commonjs2',
  36. filename: 'extension.js',
  37. path: path.resolve(__dirname, 'out')
  38. },
  39. resolve: {
  40. extensions: ['.ts']
  41. },
  42. externals: [
  43. nodeExternals()
  44. ],
  45. devtool: sourceMaps ? 'inline-source-map' : false,
  46. module: {
  47. rules: [
  48. {
  49. test: /\.ts$/,
  50. use: [{ loader: 'ts-loader' }],
  51. exclude: /node_modules/
  52. }
  53. ]
  54. },
  55. plugins: plugins
  56. };
  57. };