webpack.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const path = require('path');
  2. const Dotenv = require('dotenv-webpack');
  3. const HtmlWebpackPlugin = require('html-webpack-plugin');
  4. const CopyPlugin = require('copy-webpack-plugin');
  5. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
  6. .BundleAnalyzerPlugin;
  7. module.exports = {
  8. entry: './src/index.tsx',
  9. resolve: {
  10. extensions: ['.ts', '.tsx', '.js']
  11. },
  12. output: {
  13. path: path.join(__dirname, 'dist'),
  14. filename: 'bundle.min.js',
  15. library: 'SimpleWebRTC',
  16. libraryExport: 'default'
  17. },
  18. module: {
  19. rules: [
  20. {
  21. test: /\.tsx?$/,
  22. loader: 'awesome-typescript-loader'
  23. }
  24. ]
  25. },
  26. plugins: [
  27. new Dotenv({
  28. path: './.env'
  29. }),
  30. new HtmlWebpackPlugin({
  31. filename: 'index.html',
  32. template: './public/index.html',
  33. inject: 'head',
  34. title: process.env.META_TITLE,
  35. environment: {
  36. talky: process.env.TALKY_API_KEY,
  37. url: process.env.URL,
  38. desc: process.env.META_DESC,
  39. img: process.env.META_IMG
  40. }
  41. }),
  42. // new CopyPlugin([
  43. // {from:'public/style.css',to:'style.css'},
  44. // {from:'public/chat.png',to:'chat.png'},
  45. // ]),
  46. new BundleAnalyzerPlugin({
  47. analyzerMode: process.env.ANALYZE ? 'server' : 'disabled'
  48. })
  49. ]
  50. };