2
0

webpack.common.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. {
  32. test: /LC_MESSAGES[\\/]converse.po$/,
  33. type: "json",
  34. use: [
  35. {
  36. loader: 'po-loader',
  37. options: {
  38. 'format': 'jed',
  39. 'domain': 'converse'
  40. }
  41. }
  42. ]
  43. }, {
  44. test: /webfonts[\\/].*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  45. type: 'asset/resource',
  46. generator: {
  47. filename: '[name][ext]',
  48. publicPath: 'webfonts/',
  49. outputPath: 'webfonts/'
  50. }
  51. }, {
  52. test: /\.scss$/,
  53. use: [
  54. 'style-loader',
  55. {
  56. loader: 'css-loader',
  57. options: {
  58. sourceMap: true
  59. }
  60. },
  61. 'postcss-loader',
  62. {
  63. loader: 'sass-loader',
  64. options: {
  65. sassOptions: {
  66. includePaths: [
  67. path.resolve(__dirname, '../node_modules/'),
  68. path.resolve(__dirname, '../src/')
  69. ]
  70. },
  71. sourceMap: true
  72. }
  73. }
  74. ]
  75. }, {
  76. test: /\.js$/,
  77. include: [
  78. /src/,
  79. /node_modules\/mergebounce/,
  80. /node_modules\/lit-html/,
  81. /node_modules\/strophe/,
  82. /node_modules\/pluggable/,
  83. /node_modules\/@converse/,
  84. ],
  85. use: {
  86. loader: 'babel-loader'
  87. }
  88. }, {
  89. test: /bootstrap\.native/,
  90. use: {
  91. loader: 'bootstrap.native-loader',
  92. options: {
  93. bs_version: 4,
  94. ignore: bootstrap_ignore_modules
  95. }
  96. }
  97. }],
  98. },
  99. resolve: {
  100. extensions: ['.js'],
  101. modules: [
  102. 'node_modules',
  103. path.resolve(__dirname, "../src")
  104. ],
  105. alias: {
  106. "IPv6": path.resolve(__dirname, "../node_modules/urijs/src/IPv6"),
  107. "SecondLevelDomains": path.resolve(__dirname, "../node_modules/urijs/src/SecondLevelDomains"),
  108. "formdata-polyfill": path.resolve(__dirname, "../node_modules/formdata-polyfill/FormData"),
  109. "punycode": path.resolve(__dirname, "../node_modules/urijs/src/punycode"),
  110. "./shims": path.resolve(__dirname, "../src/strophe-shims.js"),
  111. }
  112. }
  113. }