Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

webpack-shared-config.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* global __dirname */
  2. const process = require('process');
  3. const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  4. const analyzeBundle = process.argv.indexOf('--analyze-bundle') !== -1;
  5. const minimize
  6. = process.argv.indexOf('-p') !== -1
  7. || process.argv.indexOf('--optimize-minimize') !== -1;
  8. module.exports = {
  9. // The inline-source-map is used to allow debugging the unit tests with Karma
  10. devtool: minimize ? 'source-map' : 'inline-source-map',
  11. mode: minimize ? 'production' : 'development',
  12. module: {
  13. rules: [ {
  14. // Version this build of the lib-jitsi-meet library.
  15. loader: 'string-replace-loader',
  16. options: {
  17. flags: 'g',
  18. replace:
  19. process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
  20. search: '{#COMMIT_HASH#}'
  21. },
  22. test: `${__dirname}/JitsiMeetJS.js`
  23. }, {
  24. // Transpile ES2015 (aka ES6) to ES5.
  25. loader: 'babel-loader',
  26. options: {
  27. presets: [
  28. [
  29. '@babel/preset-env',
  30. // Tell babel to avoid compiling imports into CommonJS
  31. // so that webpack may do tree shaking.
  32. {
  33. modules: false,
  34. // Specify our target browsers so no transpiling is
  35. // done unnecessarily. For browsers not specified
  36. // here, the ES2015+ profile will be used.
  37. targets: {
  38. chrome: 58,
  39. electron: 2,
  40. firefox: 54,
  41. safari: 11
  42. }
  43. }
  44. ]
  45. ],
  46. plugins: [
  47. '@babel/plugin-proposal-class-properties',
  48. '@babel/plugin-proposal-optional-chaining',
  49. '@babel/plugin-proposal-export-namespace-from',
  50. '@babel/plugin-proposal-nullish-coalescing-operator'
  51. ]
  52. },
  53. test: /\.js$/
  54. } ]
  55. },
  56. node: {
  57. // Allow the use of the real filename of the module being executed. By
  58. // default Webpack does not leak path-related information and provides a
  59. // value that is a mock (/index.js).
  60. __filename: true
  61. },
  62. optimization: {
  63. concatenateModules: minimize
  64. },
  65. output: {
  66. filename: `[name]${minimize ? '.min' : ''}.js`,
  67. path: process.cwd(),
  68. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  69. },
  70. performance: {
  71. hints: minimize ? 'error' : false,
  72. maxAssetSize: 750 * 1024,
  73. maxEntrypointSize: 750 * 1024
  74. },
  75. plugins: [
  76. analyzeBundle
  77. && new BundleAnalyzerPlugin({
  78. analyzerMode: 'disabled',
  79. generateStatsFile: true
  80. })
  81. ].filter(Boolean)
  82. };