webpack.build.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* global __dirname, module, process */
  2. const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
  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 webpack = require('webpack');
  8. const { merge } = require("webpack-merge");
  9. const plugins = [
  10. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  11. new MiniCssExtractPlugin({filename: '../dist/converse.css'}),
  12. new CopyWebpackPlugin({
  13. patterns: [
  14. {from: 'node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
  15. {from: 'sounds', to: 'sounds'},
  16. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  17. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  18. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  19. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  20. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  21. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  22. {from: 'logo/conversejs-filled.svg', to: 'images/logo'},
  23. {from: 'logo/conversejs-gold-gradient.svg', to: 'images/logo'},
  24. {from: 'src/shared/styles/webfonts', to: 'webfonts'}
  25. ]
  26. }),
  27. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  28. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  29. })
  30. ];
  31. module.exports = merge(common, {
  32. plugins,
  33. entry: {
  34. "converse": path.resolve(__dirname, "../src/entry.js"),
  35. "converse.min": path.resolve(__dirname, "../src/entry.js"),
  36. },
  37. output: {
  38. publicPath: ASSET_PATH,
  39. filename: "[name].js",
  40. },
  41. mode: "production",
  42. module: {
  43. rules: [{
  44. test: /\.scss$/,
  45. use: [
  46. MiniCssExtractPlugin.loader,
  47. {
  48. loader: 'css-loader',
  49. options: {
  50. url: false,
  51. sourceMap: true
  52. }
  53. },
  54. {
  55. loader: "postcss-loader",
  56. options: { sourceMap: true }
  57. },
  58. {
  59. loader: 'sass-loader',
  60. options: {
  61. sassOptions: {
  62. includePaths: [
  63. path.resolve(__dirname, '../node_modules/'),
  64. path.resolve(__dirname, '../src/')
  65. ]
  66. },
  67. sourceMap: true
  68. }
  69. },
  70. ]
  71. }]
  72. }
  73. });