webpack.config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const TerserPlugin = require('terser-webpack-plugin');
  4. const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
  5. module.exports = function getWebpackConfig({ minimize }){
  6. return {
  7. mode: 'production',
  8. bail: true,
  9. devtool: 'source-map',
  10. entry: {
  11. index: ['./lib/es/index.js']
  12. },
  13. output: {
  14. filename: minimize ? 'umd/semi-illustrations.min.js' : 'umd/semi-illustrations.js',
  15. path: path.join(__dirname, 'dist'),
  16. library: 'SemiIllustrations',
  17. libraryTarget: 'umd'
  18. },
  19. optimization: {
  20. minimize: !!minimize,
  21. minimizer: [new TerserPlugin()]
  22. },
  23. performance: { maxEntrypointSize: 10485760, maxAssetSize: 5242880 },
  24. plugins: [
  25. new webpack.DefinePlugin({
  26. 'process.env': { NODE_ENV: '"production"' }
  27. }),
  28. new CaseSensitivePathsPlugin(),
  29. new webpack.HashedModuleIdsPlugin(),
  30. ],
  31. resolve: {
  32. extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
  33. },
  34. externals: {
  35. react: {
  36. root: 'React',
  37. commonjs2: 'react',
  38. commonjs: 'react',
  39. amd: 'react'
  40. }
  41. }
  42. };
  43. };