webpack.prod.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* global __dirname, module, process */
  2. const common = require("./webpack.common.js");
  3. const merge = require("webpack-merge");
  4. const path = require('path');
  5. const webpack = require('webpack');
  6. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  7. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  8. const CopyWebpackPlugin = require('copy-webpack-plugin');
  9. const ASSET_PATH = process.env.ASSET_PATH || '/dist/'; // eslint-disable-line no-process-env
  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. {from: 'sounds', to: 'sounds'},
  22. {from: 'node_modules/@fortawesome/fontawesome-free/sprites/solid.svg', to: '@fortawesome/fontawesome-free/sprites/solid.svg'},
  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. new webpack.DefinePlugin({ // This makes it possible for us to safely use env vars on our code
  32. 'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH)
  33. })
  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: [path.resolve(__dirname, 'node_modules/')]
  55. },
  56. sourceMap: true
  57. }
  58. }
  59. ]
  60. }]
  61. }
  62. });