2
0

webpack.build.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* global __dirname, module, process */
  2. const CircularDependencyPlugin = require('circular-dependency-plugin');
  3. const CopyWebpackPlugin = require('copy-webpack-plugin');
  4. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  5. const common = require("./webpack.common.js");
  6. const path = require('path');
  7. const { merge } = require("webpack-merge");
  8. const plugins = [
  9. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  10. new MiniCssExtractPlugin({filename: '../dist/converse.css'}),
  11. new CopyWebpackPlugin({
  12. patterns: [
  13. {from: 'node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
  14. {from: 'sounds', to: 'sounds'},
  15. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  16. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  17. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  18. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  19. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  20. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  21. {from: 'logo/conversejs-filled.svg', to: 'images/logo'},
  22. {from: 'logo/conversejs-gold-gradient.svg', to: 'images/logo'},
  23. {from: 'src/shared/styles/webfonts', to: 'webfonts'},
  24. {from: 'manifest.json', to: 'manifest.json'}
  25. ]
  26. }),
  27. new CircularDependencyPlugin({
  28. exclude: /node_modules/,
  29. failOnError: true,
  30. allowAsyncCycles: false,
  31. cwd: process.cwd(),
  32. })
  33. ];
  34. module.exports = merge(common, {
  35. plugins,
  36. entry: {
  37. "converse": path.resolve(__dirname, "../src/entry.js"),
  38. "converse.min": path.resolve(__dirname, "../src/entry.js"),
  39. },
  40. output: {
  41. filename: "[name].js",
  42. },
  43. mode: "production",
  44. module: {
  45. rules: [{
  46. test: /\.(js|ts)$/,
  47. use: [{
  48. loader: 'minify-html-literals-loader'
  49. }]
  50. },
  51. {
  52. test: /\.scss$/,
  53. use: [
  54. MiniCssExtractPlugin.loader,
  55. {
  56. loader: 'css-loader',
  57. options: {
  58. url: false,
  59. sourceMap: true
  60. }
  61. },
  62. {
  63. loader: "postcss-loader",
  64. options: { sourceMap: true }
  65. },
  66. {
  67. loader: 'sass-loader',
  68. options: {
  69. sassOptions: {
  70. silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'mixed-decls'],
  71. includePaths: [
  72. path.resolve(__dirname, '../node_modules/'),
  73. path.resolve(__dirname, '../src/')
  74. ]
  75. },
  76. sourceMap: true
  77. }
  78. },
  79. ]
  80. }]
  81. }
  82. });