You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.3 KiB

  1. /*
  2. * @copyright Copyright (c) 2022 Grigorii Shartsev <me@shgk.me>
  3. *
  4. * @author Grigorii Shartsev <me@shgk.me>
  5. *
  6. * @license AGPL-3.0-or-later
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except')
  22. const { mergeWithRules } = require('webpack-merge')
  23. const nextcloudWebpackRules = require('@nextcloud/webpack-vue-config/rules')
  24. // Replace rules with the same modules
  25. module.exports = mergeWithRules({
  26. module: {
  27. rules: {
  28. test: 'match',
  29. loader: 'replace',
  30. options: 'replace',
  31. use: 'replace',
  32. },
  33. },
  34. })({
  35. module: {
  36. // Reuse @nextcloud/webpack-vue-config/rules
  37. rules: Object.values(nextcloudWebpackRules),
  38. },
  39. },
  40. {
  41. module: {
  42. rules: [
  43. {
  44. test: /\.js$/,
  45. loader: 'esbuild-loader',
  46. options: {
  47. // Implicitly set as JS loader for only JS parts of Vue SFCs will be transpiled
  48. loader: 'js',
  49. target: 'es2020',
  50. },
  51. exclude: BabelLoaderExcludeNodeModulesExcept([
  52. '@nextcloud/event-bus',
  53. 'ansi-regex',
  54. 'fast-xml-parser',
  55. 'hot-patcher',
  56. 'nextcloud-vue-collections',
  57. 'semver',
  58. 'strip-ansi',
  59. 'tributejs',
  60. 'webdav',
  61. ]),
  62. },
  63. {
  64. test: /\.tsx?$/,
  65. use: [{
  66. loader: 'esbuild-loader',
  67. options: {
  68. // Implicitly set as TS loader so only <script lang="ts"> Vue SFCs will be transpiled
  69. loader: 'ts',
  70. target: 'es2020',
  71. },
  72. }]
  73. },
  74. {
  75. test: /\.wasm$/i,
  76. type: 'asset/resource',
  77. },
  78. {
  79. test: /\.tflite$/i,
  80. type: 'asset/resource',
  81. },
  82. {
  83. test: /\.worker\.js$/,
  84. use: { loader: 'worker-loader' },
  85. },
  86. {
  87. resourceQuery: /raw/,
  88. type: 'asset/source',
  89. }
  90. ],
  91. },
  92. })