webpack.prod.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 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: 'src/shared/styles/webfonts', to: 'webfonts'}
  23. ]
  24. }),
  25. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  26. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  27. })
  28. ];
  29. module.exports = merge(common, {
  30. plugins,
  31. output: {
  32. publicPath: ASSET_PATH,
  33. filename: 'converse.min.js',
  34. },
  35. mode: "production",
  36. devtool: "source-map",
  37. module: {
  38. rules: [{
  39. test: /\.scss$/,
  40. use: [
  41. MiniCssExtractPlugin.loader,
  42. {
  43. loader: 'css-loader',
  44. options: {
  45. url: false,
  46. sourceMap: true
  47. }
  48. },
  49. 'postcss-loader',
  50. {
  51. loader: 'sass-loader',
  52. options: {
  53. sassOptions: {
  54. includePaths: [
  55. path.resolve(__dirname, '../node_modules/'),
  56. path.resolve(__dirname, '../src/')
  57. ]
  58. },
  59. sourceMap: true
  60. }
  61. }
  62. ]
  63. }]
  64. }
  65. });