rspack.common.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. const { rspack } = require('@rspack/core');
  2. const path = require('path');
  3. module.exports = {
  4. plugins: [
  5. new rspack.DefinePlugin({
  6. 'process.env.ASSET_PATH': JSON.stringify(process.env.ASSET_PATH || '/dist/'),
  7. }),
  8. new rspack.CircularDependencyRspackPlugin({
  9. exclude: /node_modules/,
  10. failOnError: true,
  11. allowAsyncCycles: false,
  12. cwd: process.cwd(),
  13. }),
  14. ],
  15. output: {
  16. path: path.resolve(__dirname, '../dist'),
  17. publicPath: process.env.ASSET_PATH || '/dist/',
  18. chunkFilename: '[name].js',
  19. },
  20. devtool: 'source-map',
  21. module: {
  22. rules: [
  23. {
  24. test: /LC_MESSAGES[\\/]converse.po$/,
  25. type: 'json',
  26. use: [
  27. {
  28. loader: 'po-loader',
  29. options: {
  30. 'format': 'jed',
  31. 'domain': 'converse',
  32. },
  33. },
  34. ],
  35. },
  36. {
  37. test: /webfonts[\\/].*\.(woff(2)?|ttf|eot|truetype|svg)(\?v=\d+\.\d+\.\d+)?$/,
  38. type: 'asset/resource',
  39. generator: {
  40. filename: '[name][ext]',
  41. publicPath: 'webfonts/',
  42. outputPath: 'webfonts/',
  43. },
  44. },
  45. {
  46. test: /\.scss$/,
  47. use: [
  48. 'style-loader',
  49. {
  50. loader: 'css-loader',
  51. options: {
  52. url: false,
  53. sourceMap: true,
  54. },
  55. },
  56. {
  57. loader: 'postcss-loader',
  58. options: { sourceMap: true },
  59. },
  60. {
  61. loader: 'sass-loader',
  62. options: {
  63. sassOptions: {
  64. silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'mixed-decls'],
  65. includePaths: [
  66. path.resolve(__dirname, '../node_modules/'),
  67. path.resolve(__dirname, '../src/'),
  68. ],
  69. },
  70. sourceMap: true,
  71. },
  72. },
  73. ],
  74. },
  75. ],
  76. },
  77. resolve: {
  78. extensions: ['.js'],
  79. modules: ['node_modules', path.resolve(__dirname, '../src')],
  80. alias: {
  81. 'IPv6': path.resolve(__dirname, '../node_modules/urijs/src/IPv6'),
  82. 'SecondLevelDomains': path.resolve(__dirname, '../node_modules/urijs/src/SecondLevelDomains'),
  83. 'punycode': path.resolve(__dirname, '../node_modules/urijs/src/punycode'),
  84. },
  85. },
  86. watchOptions: {
  87. ignored: [
  88. path.posix.resolve(__dirname, '../node_modules'),
  89. path.posix.resolve(__dirname, '../3rdparty'),
  90. path.posix.resolve(__dirname, '../dist'),
  91. ],
  92. },
  93. };