webpack.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* eslint-disable @typescript-eslint/no-var-requires */
  2. const path = require('path');
  3. const webpack = require('webpack'); //to access built-in plugins
  4. const sourceMapPlugin = new webpack.SourceMapDevToolPlugin({
  5. filename: 'sourcemaps/[file].map',
  6. fileContext: 'public',
  7. });
  8. // devtool: 'inline-source-map',
  9. module.exports = [
  10. {
  11. mode: 'production',
  12. name: 'minimized-prod',
  13. entry: {
  14. 'animation-timeline': './src/animation-timeline.ts',
  15. },
  16. module: {
  17. rules: [
  18. {
  19. test: /\.tsx?$/,
  20. loader: 'babel-loader',
  21. exclude: [/node_modules/, /lib/],
  22. },
  23. ],
  24. },
  25. resolve: {
  26. extensions: ['.tsx', '.ts'],
  27. },
  28. output: {
  29. filename: '[name].min.js',
  30. libraryTarget: 'umd',
  31. library: 'timelineModule',
  32. // eslint-disable-next-line no-undef
  33. path: path.resolve(__dirname, 'lib'),
  34. },
  35. },
  36. {
  37. // Development unminimized file
  38. mode: 'production',
  39. name: 'unminimized',
  40. entry: {
  41. 'animation-timeline': './src/animation-timeline.ts',
  42. },
  43. module: {
  44. rules: [
  45. {
  46. test: /\.tsx?$/,
  47. loader: 'babel-loader',
  48. exclude: [/node_modules/, /lib/],
  49. },
  50. ],
  51. },
  52. resolve: {
  53. extensions: ['.tsx', '.ts'],
  54. },
  55. optimization: {
  56. minimize: false,
  57. },
  58. output: {
  59. filename: '[name].js',
  60. libraryTarget: 'umd',
  61. library: 'timelineModule',
  62. // eslint-disable-next-line no-undef
  63. path: path.resolve(__dirname, 'lib'),
  64. },
  65. // Add source maps for the dev instance
  66. plugins: [sourceMapPlugin],
  67. },
  68. ];