Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

webpack.config.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. '@babel/preset-env',
  46. // Tell babel to avoid compiling imports into CommonJS
  47. // so that webpack may do tree shaking.
  48. { modules: false }
  49. ],
  50. '@babel/preset-flow'
  51. ],
  52. plugins: [
  53. '@babel/plugin-transform-flow-strip-types',
  54. '@babel/plugin-proposal-class-properties',
  55. '@babel/plugin-proposal-export-namespace-from'
  56. ]
  57. },
  58. test: /\.js$/
  59. } ]
  60. },
  61. node: {
  62. // Allow the use of the real filename of the module being executed. By
  63. // default Webpack does not leak path-related information and provides a
  64. // value that is a mock (/index.js).
  65. __filename: true
  66. },
  67. output: {
  68. filename: `[name]${minimize ? '.min' : ''}.js`,
  69. sourceMapFilename: `[name].${minimize ? 'min' : 'js'}.map`
  70. },
  71. plugins
  72. };
  73. module.exports = [
  74. Object.assign({}, config, {
  75. entry: {
  76. 'lib-jitsi-meet': './index.js'
  77. },
  78. output: Object.assign({}, config.output, {
  79. library: 'JitsiMeetJS',
  80. libraryTarget: 'umd'
  81. })
  82. })
  83. ];