webpack.common.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* global __dirname, module, process */
  2. const path = require('path');
  3. let bootstrap_ignore_modules = ['carousel', 'scrollspy'];
  4. const BOOTSTRAP_IGNORE_MODULES = (process.env.BOOTSTRAP_IGNORE_MODULES || '').replace(/ /g, '').trim();
  5. if (BOOTSTRAP_IGNORE_MODULES.length > 0) {
  6. bootstrap_ignore_modules = bootstrap_ignore_modules.concat(BOOTSTRAP_IGNORE_MODULES.split(','));
  7. }
  8. module.exports = {
  9. output: {
  10. path: path.resolve(__dirname, 'dist'), // Output path for generated bundles
  11. chunkFilename: '[name].js'
  12. },
  13. entry: path.resolve(__dirname, 'src/entry.js'),
  14. externals: [{
  15. "window": "window"
  16. }],
  17. watchOptions: {
  18. ignored: [/dist/, /spec/, /.*\~/]
  19. },
  20. module: {
  21. rules: [
  22. {
  23. test: path.resolve(__dirname, "node_modules/xss/dist/xss"),
  24. use: "exports-loader?filterXSS,filterCSS"
  25. },
  26. {
  27. test: /\.(html|svg)$/,
  28. exclude: /node_modules/,
  29. use: [{
  30. loader: 'lodash-template-webpack-loader',
  31. options: {
  32. "escape": /\{\{\{([\s\S]+?)\}\}\}/g,
  33. "evaluate": /\{\[([\s\S]+?)\]\}/g,
  34. "interpolate": /\{\{([\s\S]+?)\}\}/g,
  35. // By default, template places the values from your data in the
  36. // local scope via the with statement. However, you can specify
  37. // a single variable name with the variable setting. This can
  38. // significantly improve the speed at which a template is able
  39. // to render.
  40. "variable": 'o',
  41. "prependFilenameComment": __dirname
  42. }
  43. }]
  44. }, {
  45. test: /LC_MESSAGES\/converse.po$/,
  46. type: "json",
  47. use: [
  48. {
  49. loader: 'po-loader',
  50. options: {
  51. 'format': 'jed',
  52. 'domain': 'converse'
  53. }
  54. }
  55. ]
  56. }, {
  57. test: /webfonts\/.*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  58. use: [
  59. {
  60. loader: 'file-loader',
  61. options: {
  62. name: '[name].[ext]',
  63. outputPath: 'webfonts/'
  64. }
  65. }
  66. ]
  67. }, {
  68. test: /\.scss$/,
  69. use: [
  70. 'style-loader',
  71. {
  72. loader: 'css-loader',
  73. options: {
  74. sourceMap: true
  75. }
  76. },
  77. 'postcss-loader',
  78. {
  79. loader: 'sass-loader',
  80. options: {
  81. sassOptions: {
  82. includePaths: [path.resolve(__dirname, 'node_modules/')]
  83. },
  84. sourceMap: true
  85. }
  86. }
  87. ]
  88. }, {
  89. test: /\.js$/,
  90. include: /src/,
  91. use: {
  92. loader: 'babel-loader',
  93. options: {
  94. presets: [
  95. ["@babel/preset-env", {
  96. "targets": {
  97. "browsers": [">1%", "not ie 11", "not op_mini all"]
  98. }
  99. }]
  100. ],
  101. plugins: [
  102. 'lodash',
  103. '@babel/plugin-proposal-class-properties',
  104. '@babel/plugin-proposal-nullish-coalescing-operator',
  105. '@babel/plugin-proposal-optional-chaining',
  106. '@babel/plugin-syntax-dynamic-import'
  107. ]
  108. }
  109. }
  110. }, {
  111. test: /bootstrap\.native/,
  112. use: {
  113. loader: 'bootstrap.native-loader',
  114. options: {
  115. bs_version: 4,
  116. ignore: bootstrap_ignore_modules
  117. }
  118. }
  119. }],
  120. },
  121. resolve: {
  122. extensions: ['.js'],
  123. modules: [
  124. 'node_modules',
  125. path.resolve(__dirname, "src")
  126. ],
  127. alias: {
  128. "IPv6": path.resolve(__dirname, "node_modules/urijs/src/IPv6"),
  129. "SecondLevelDomains": path.resolve(__dirname, "node_modules/urijs/src/SecondLevelDomains"),
  130. "formdata-polyfill": path.resolve(__dirname, "node_modules/formdata-polyfill/FormData"),
  131. "punycode": path.resolve(__dirname, "node_modules/urijs/src/punycode")
  132. }
  133. }
  134. }