webpack.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const path = require('path')
  2. const TerserPlugin = require('terser-webpack-plugin')
  3. const UnminifiedWebpackPlugin = require('unminified-webpack-plugin')
  4. const paths = {
  5. source: path.resolve(__dirname, 'src'),
  6. es5: path.resolve(__dirname, 'dist', 'es5'),
  7. }
  8. const commonConfig = {
  9. output: {
  10. filename: '[name].min.js',
  11. path: paths.es5,
  12. library: 'rrule',
  13. libraryTarget: 'umd',
  14. globalObject: "typeof self !== 'undefined' ? self : this",
  15. },
  16. devtool: 'source-map',
  17. mode: 'production',
  18. resolve: {
  19. extensions: ['.js', '.ts'],
  20. },
  21. module: {
  22. rules: [
  23. {
  24. exclude: /node_modules/,
  25. loader: 'ts-loader',
  26. test: /\.ts$/,
  27. options: {
  28. configFile: 'tsconfig.build.json',
  29. },
  30. },
  31. ],
  32. },
  33. optimization: {
  34. minimize: true,
  35. minimizer: [new TerserPlugin()],
  36. },
  37. plugins: [new UnminifiedWebpackPlugin()],
  38. }
  39. const rruleConfig = Object.assign(
  40. {
  41. entry: {
  42. rrule: path.join(paths.source, 'index.ts'),
  43. },
  44. },
  45. commonConfig
  46. )
  47. module.exports = [rruleConfig]