webpack.prod.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 { CleanWebpackPlugin } = require('clean-webpack-plugin');
  9. const { merge} = require("webpack-merge");
  10. module.exports = merge(common, {
  11. output: {
  12. publicPath: ASSET_PATH,
  13. filename: 'converse.min.js',
  14. },
  15. plugins: [
  16. new CleanWebpackPlugin({
  17. cleanStaleWebpackAssets: false // resolves conflict with CopyWebpackPlugin
  18. }),
  19. new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
  20. new CopyWebpackPlugin({
  21. patterns: [
  22. {from: 'sounds', to: 'sounds'},
  23. {from: 'images/favicon.ico', to: 'images/favicon.ico'},
  24. {from: 'images/custom_emojis', to: 'images/custom_emojis'},
  25. {from: 'logo/conversejs-filled-192.png', to: 'images/logo'},
  26. {from: 'logo/conversejs-filled-512.png', to: 'images/logo'},
  27. {from: 'logo/conversejs-filled-192.svg', to: 'images/logo'},
  28. {from: 'logo/conversejs-filled-512.svg', to: 'images/logo'},
  29. {from: 'sass/webfonts', to: 'webfonts'}
  30. ]
  31. }),
  32. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  33. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  34. })
  35. ],
  36. mode: "production",
  37. devtool: "source-map",
  38. module: {
  39. rules: [{
  40. test: /\.scss$/,
  41. use: [
  42. MiniCssExtractPlugin.loader,
  43. {
  44. loader: 'css-loader',
  45. options: {
  46. url: false,
  47. sourceMap: true
  48. }
  49. },
  50. 'postcss-loader',
  51. {
  52. loader: 'sass-loader',
  53. options: {
  54. sassOptions: {
  55. includePaths: [path.resolve(__dirname, 'node_modules/')]
  56. },
  57. sourceMap: true
  58. }
  59. }
  60. ]
  61. }]
  62. }
  63. });