webpack.common.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* global __dirname, module, process */
  2. const TerserPlugin = require("terser-webpack-plugin");
  3. const path = require('path');
  4. let bootstrap_ignore_modules = ['carousel', 'scrollspy', 'tooltip', 'toast'];
  5. const BOOTSTRAP_IGNORE_MODULES = (process.env.BOOTSTRAP_IGNORE_MODULES || '').replace(/ /g, '').trim();
  6. if (BOOTSTRAP_IGNORE_MODULES.length > 0) {
  7. bootstrap_ignore_modules = bootstrap_ignore_modules.concat(BOOTSTRAP_IGNORE_MODULES.split(','));
  8. }
  9. module.exports = {
  10. output: {
  11. path: path.resolve(__dirname, '../dist'), // Output path for generated bundles
  12. chunkFilename: '[name].js'
  13. },
  14. devtool: "source-map",
  15. optimization: {
  16. minimize: true,
  17. minimizer: [
  18. new TerserPlugin({
  19. include: /\.min\.js$/
  20. })
  21. ],
  22. },
  23. externals: [{
  24. "window": "window"
  25. }],
  26. watchOptions: {
  27. ignored: /dist/,
  28. },
  29. module: {
  30. rules: [{
  31. test: /LC_MESSAGES[\\/]converse.po$/,
  32. type: "json",
  33. use: [
  34. {
  35. loader: 'po-loader',
  36. options: {
  37. 'format': 'jed',
  38. 'domain': 'converse'
  39. }
  40. }
  41. ]
  42. }, {
  43. test: /webfonts[\\/].*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  44. type: 'asset/resource',
  45. generator: {
  46. filename: '[name][ext]',
  47. publicPath: 'webfonts/',
  48. outputPath: 'webfonts/'
  49. }
  50. }, {
  51. test: /\.scss$/,
  52. use: [
  53. 'style-loader',
  54. {
  55. loader: 'css-loader',
  56. options: {
  57. url: false,
  58. sourceMap: true
  59. }
  60. },
  61. {
  62. loader: "postcss-loader",
  63. options: { sourceMap: true }
  64. },
  65. {
  66. loader: 'sass-loader',
  67. options: {
  68. sassOptions: {
  69. includePaths: [
  70. path.resolve(__dirname, '../node_modules/'),
  71. path.resolve(__dirname, '../src/')
  72. ]
  73. },
  74. sourceMap: true
  75. }
  76. },
  77. ]
  78. }, {
  79. test: /\.js$/,
  80. include: [
  81. /src/,
  82. /node_modules\/mergebounce/,
  83. /node_modules\/lit-html/,
  84. /node_modules\/strophe/,
  85. /node_modules\/pluggable/,
  86. /node_modules\/@converse/,
  87. ],
  88. use: {
  89. loader: 'babel-loader'
  90. }
  91. }, {
  92. test: /bootstrap\.native/,
  93. use: {
  94. loader: 'bootstrap.native-loader',
  95. options: {
  96. bs_version: 4,
  97. ignore: bootstrap_ignore_modules
  98. }
  99. }
  100. }],
  101. },
  102. resolve: {
  103. extensions: ['.js'],
  104. modules: [
  105. 'node_modules',
  106. path.resolve(__dirname, "../src")
  107. ],
  108. alias: {
  109. "IPv6": path.resolve(__dirname, "../node_modules/urijs/src/IPv6"),
  110. "SecondLevelDomains": path.resolve(__dirname, "../node_modules/urijs/src/SecondLevelDomains"),
  111. "punycode": path.resolve(__dirname, "../node_modules/urijs/src/punycode"),
  112. "./shims.js": path.resolve(__dirname, "../src/strophe-shims.js"),
  113. "./shims": path.resolve(__dirname, "../src/strophe-shims.js"),
  114. }
  115. }
  116. }