webpack.common.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. test: /LC_MESSAGES\/converse.po$/,
  27. type: "json",
  28. use: [
  29. {
  30. loader: 'po-loader',
  31. options: {
  32. 'format': 'jed',
  33. 'domain': 'converse'
  34. }
  35. }
  36. ]
  37. }, {
  38. test: /webfonts\/.*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  39. use: [
  40. {
  41. loader: 'file-loader',
  42. options: {
  43. name: '[name].[ext]',
  44. outputPath: 'webfonts/'
  45. }
  46. }
  47. ]
  48. }, {
  49. test: /\.scss$/,
  50. use: [
  51. 'style-loader',
  52. {
  53. loader: 'css-loader',
  54. options: {
  55. sourceMap: true
  56. }
  57. },
  58. 'postcss-loader',
  59. {
  60. loader: 'sass-loader',
  61. options: {
  62. sassOptions: {
  63. includePaths: [path.resolve(__dirname, 'node_modules/')]
  64. },
  65. sourceMap: true
  66. }
  67. }
  68. ]
  69. }, {
  70. test: /\.js$/,
  71. include: /src/,
  72. use: {
  73. loader: 'babel-loader',
  74. options: {
  75. presets: [
  76. ["@babel/preset-env", {
  77. "targets": {
  78. "browsers": [">1%", "not ie 11", "not op_mini all"]
  79. }
  80. }]
  81. ],
  82. plugins: [
  83. 'lodash',
  84. '@babel/plugin-proposal-class-properties',
  85. '@babel/plugin-proposal-nullish-coalescing-operator',
  86. '@babel/plugin-proposal-optional-chaining',
  87. '@babel/plugin-syntax-dynamic-import'
  88. ]
  89. }
  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. "formdata-polyfill": path.resolve(__dirname, "node_modules/formdata-polyfill/FormData"),
  112. "punycode": path.resolve(__dirname, "node_modules/urijs/src/punycode")
  113. }
  114. }
  115. }