您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

webpack.config.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* global __dirname */
  2. const process = require('process');
  3. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  4. const webpack = require('webpack');
  5. const minimize
  6. = process.argv.indexOf('-p') !== -1
  7. || process.argv.indexOf('--optimize-minimize') !== -1;
  8. const plugins = [
  9. new webpack.LoaderOptionsPlugin({
  10. debug: !minimize,
  11. minimize
  12. })
  13. ];
  14. if (minimize) {
  15. plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
  16. plugins.push(new UglifyJsPlugin({
  17. cache: true,
  18. extractComments: true,
  19. parallel: true,
  20. sourceMap: true
  21. }));
  22. }
  23. const config = {
  24. devtool: 'source-map',
  25. module: {
  26. rules: [ {
  27. // Version this build of the lib-jitsi-meet library.
  28. loader: 'string-replace-loader',
  29. options: {
  30. flags: 'g',
  31. replace:
  32. process.env.LIB_JITSI_MEET_COMMIT_HASH || 'development',
  33. search: '{#COMMIT_HASH#}'
  34. },
  35. test: `${__dirname}/JitsiMeetJS.js`
  36. }, {
  37. // Transpile ES2015 (aka ES6) to ES5.
  38. exclude: [
  39. new RegExp(`${__dirname}/node_modules/(?!js-utils)`)
  40. ],
  41. loader: 'babel-loader',
  42. options: {
  43. presets: [
  44. [
  45. 'env',
  46. // Tell babel to avoid compiling imports into CommonJS
  47. // so that webpack may do tree shaking.
  48. { modules: false }
  49. ],
  50. 'stage-1'
  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. output: {
  63. filename: `[name]${minimize ? '.min' : ''}.js`,
  64. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  65. },
  66. plugins
  67. };
  68. module.exports = [
  69. Object.assign({}, config, {
  70. entry: {
  71. 'lib-jitsi-meet': './index.js'
  72. },
  73. output: Object.assign({}, config.output, {
  74. library: 'JitsiMeetJS',
  75. libraryTarget: 'umd'
  76. })
  77. })
  78. ];