webpack.config.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const pkg = require('./package.json')
  2. const path = require('path')
  3. const webpack = require('webpack')
  4. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  5. const TerserPlugin = require('terser-webpack-plugin')
  6. module.exports = {
  7. entry: './src/LSPlugin.user.ts',
  8. module: {
  9. rules: [
  10. {
  11. test: /\.tsx?$/,
  12. use: [
  13. {
  14. loader: 'babel-loader'
  15. },
  16. {
  17. loader: 'ts-loader'
  18. }
  19. ],
  20. exclude: /node_modules/,
  21. }
  22. ],
  23. },
  24. resolve: {
  25. extensions: ['.tsx', '.ts', '.js'],
  26. },
  27. optimization: {
  28. minimize: true,
  29. minimizer: [
  30. new TerserPlugin()
  31. ]
  32. },
  33. plugins: [
  34. new webpack.ProvidePlugin({
  35. process: 'process/browser',
  36. }),
  37. new webpack.DefinePlugin({
  38. LIB_VERSION: JSON.stringify(pkg.version)
  39. })
  40. // new BundleAnalyzerPlugin()
  41. ],
  42. output: {
  43. library: 'LSPluginEntry',
  44. libraryTarget: 'umd',
  45. filename: 'lsplugin.user.js',
  46. path: path.resolve(__dirname, 'dist')
  47. },
  48. }