webpack.config.prod.js 799 B

123456789101112131415161718192021222324252627282930313233343536
  1. const path = require('path');
  2. const common = require('./webpack.config.common');
  3. const webpack = require('webpack');
  4. const genConfig = ({
  5. entry, filename, library, libraryTarget,
  6. }) => ({
  7. ...common,
  8. mode: 'production',
  9. devtool: 'source-map',
  10. entry,
  11. output: {
  12. path: path.resolve(__dirname, '..', 'dist'),
  13. filename,
  14. library,
  15. libraryTarget,
  16. },
  17. plugins: [
  18. new webpack.ProvidePlugin({
  19. Buffer: ['buffer', 'Buffer'],
  20. }),
  21. ]
  22. });
  23. module.exports = [
  24. genConfig({
  25. entry: path.resolve(__dirname, '..', 'src', 'index.js'),
  26. filename: 'tesseract.min.js',
  27. library: 'Tesseract',
  28. libraryTarget: 'umd',
  29. }),
  30. genConfig({
  31. entry: path.resolve(__dirname, '..', 'src', 'worker-script', 'browser', 'index.js'),
  32. filename: 'worker.min.js',
  33. }),
  34. ];