You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webpack.config.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* global __dirname */
  2. require('babel-polyfill'); // Define Object.assign() from ES6 in ES5.
  3. var HasteResolverPlugin = require('haste-resolver-webpack-plugin');
  4. var process = require('process');
  5. var webpack = require('webpack');
  6. var aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/';
  7. var minimize
  8. = process.argv.indexOf('-p') != -1
  9. || process.argv.indexOf('--optimize-minimize') != -1;
  10. var plugins = [
  11. new HasteResolverPlugin()
  12. ];
  13. var strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
  14. if (minimize) {
  15. // XXX Webpack's command line argument -p is not enough. Further
  16. // optimizations are made possible by the use of DefinePlugin and NODE_ENV
  17. // with value 'production'. For example, React takes advantage of these.
  18. plugins.push(new webpack.DefinePlugin({
  19. 'process.env': {
  20. NODE_ENV: JSON.stringify('production')
  21. }
  22. }));
  23. }
  24. // The base Webpack configuration to bundle the JavaScript artifacts of
  25. // jitsi-meet such as app.bundle.js and external_api.js.
  26. var config = {
  27. devtool: 'source-map',
  28. module: {
  29. loaders: [{
  30. // Transpile ES2015 (aka ES6) to ES5. Accept the JSX syntax by React
  31. // as well.
  32. exclude: __dirname + '/node_modules/',
  33. loader: 'babel',
  34. query: {
  35. presets: [
  36. 'es2015',
  37. 'react',
  38. 'stage-1'
  39. ]
  40. },
  41. test: /\.jsx?$/
  42. },{
  43. // Expose jquery as the globals $ and jQuery because it is expected
  44. // to be available in such a form by multiple jitsi-meet
  45. // dependencies including AUI, lib-jitsi-meet.
  46. loader: 'expose?$!expose?jQuery',
  47. test: /\/node_modules\/jquery\/.*\.js$/
  48. },{
  49. // Disable AMD for the Strophe.js library or its imports will fail
  50. // at runtime.
  51. loader: 'imports?define=>false&this=>window',
  52. test: strophe
  53. },{
  54. // Allow CSS to be imported into JavaScript.
  55. loaders: [
  56. 'style',
  57. 'css'
  58. ],
  59. test: /\.css$/
  60. },{
  61. // Emit the static assets of AUI such as images that are referenced
  62. // by CSS into the output path.
  63. include: aui_css,
  64. loader: 'file',
  65. query: {
  66. context: aui_css,
  67. name: '[path][name].[ext]'
  68. },
  69. test: /\.(gif|png|svg)$/
  70. },{
  71. //Adds the ability to import json files.
  72. loader: 'json',
  73. exclude: __dirname + '/node_modules/',
  74. test: /\.json$/
  75. }],
  76. noParse: [
  77. // Do not parse the files of the Strophe.js library or at least
  78. // parts of the properties of the Strophe global variable will be
  79. // missing and strophejs-plugins will fail at runtime.
  80. strophe
  81. ]
  82. },
  83. node: {
  84. // Allow the use of the real filename of the module being executed. By
  85. // default Webpack does not leak path-related information and provides a
  86. // value that is a mock (/index.js).
  87. __filename: true
  88. },
  89. output: {
  90. filename: '[name]' + (minimize ? '.min' : '') + '.js',
  91. libraryTarget: 'umd',
  92. path: __dirname + '/build',
  93. sourceMapFilename: '[name].' + (minimize ? 'min' : 'js') + '.map'
  94. },
  95. plugins: plugins,
  96. resolve: {
  97. alias: {
  98. aui:
  99. '@atlassian/aui/dist/aui/js/aui'
  100. + (minimize ? '.min' : '')
  101. + '.js',
  102. 'aui-experimental':
  103. '@atlassian/aui/dist/aui/js/aui-experimental'
  104. + (minimize ? '.min' : '')
  105. + '.js',
  106. jquery: 'jquery/dist/jquery' + (minimize ? '.min' : '') + '.js',
  107. 'jQuery-Impromptu':
  108. 'jQuery-Impromptu/dist/jquery-impromptu'
  109. + (minimize ? '.min' : '')
  110. + '.js',
  111. },
  112. packageAlias: 'browser'
  113. }
  114. };
  115. module.exports = [
  116. // The Webpack configuration to bundle app.bundle.js (aka APP).
  117. Object.assign({}, config, {
  118. entry: {
  119. 'app.bundle': './app.js'
  120. },
  121. output: Object.assign({}, config.output, {
  122. library: 'APP'
  123. })
  124. }),
  125. // The Webpack configuration to bundle external_api.js (aka
  126. // JitsiMeetExternalAPI).
  127. Object.assign({}, config, {
  128. entry: {
  129. 'external_api': './modules/API/external/external_api.js'
  130. },
  131. output: Object.assign({}, config.output, {
  132. library: 'JitsiMeetExternalAPI'
  133. })
  134. })
  135. ];