webpack.common.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* eslint-disable camelcase */
  2. const { merge } = require('webpack-merge')
  3. const { VueLoaderPlugin } = require('vue-loader')
  4. const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except')
  5. const path = require('path')
  6. const accessibility = require('./apps/accessibility/webpack')
  7. const comments = require('./apps/comments/webpack')
  8. const core = require('./core/webpack')
  9. const dashboard = require('./apps/dashboard/webpack')
  10. const dav = require('./apps/dav/webpack')
  11. const files = require('./apps/files/webpack')
  12. const files_sharing = require('./apps/files_sharing/webpack')
  13. const files_trashbin = require('./apps/files_trashbin/webpack')
  14. const files_versions = require('./apps/files_versions/webpack')
  15. const oauth2 = require('./apps/oauth2/webpack')
  16. const settings = require('./apps/settings/webpack')
  17. const systemtags = require('./apps/systemtags/webpack')
  18. const user_status = require('./apps/user_status/webpack')
  19. const weather_status = require('./apps/weather_status/webpack')
  20. const twofactor_backupscodes = require('./apps/twofactor_backupcodes/webpack')
  21. const updatenotification = require('./apps/updatenotification/webpack')
  22. const workflowengine = require('./apps/workflowengine/webpack')
  23. const modules = {
  24. accessibility,
  25. comments,
  26. core,
  27. dashboard,
  28. dav,
  29. files,
  30. files_sharing,
  31. files_trashbin,
  32. files_versions,
  33. oauth2,
  34. settings,
  35. systemtags,
  36. user_status,
  37. weather_status,
  38. twofactor_backupscodes,
  39. updatenotification,
  40. workflowengine,
  41. }
  42. const modulesToBuild = () => {
  43. const MODULE = process.env.MODULE
  44. if (MODULE) {
  45. if (!modules[MODULE]) {
  46. throw new Error(`No module "${MODULE}" found`)
  47. }
  48. return [modules[MODULE]]
  49. }
  50. return Object.values(modules)
  51. }
  52. module.exports = []
  53. .concat(
  54. ...modulesToBuild()
  55. )
  56. .map(config => merge({
  57. module: {
  58. rules: [
  59. {
  60. test: /\.css$/,
  61. use: ['style-loader', 'css-loader'],
  62. },
  63. {
  64. test: /\.scss$/,
  65. use: ['style-loader', 'css-loader', 'sass-loader'],
  66. },
  67. {
  68. test: /\.(js|vue)$/,
  69. loader: 'eslint-loader',
  70. // no checks against vendors, modules or handlebar compiled files
  71. exclude: /node_modules|vendor|templates\.js/,
  72. enforce: 'pre',
  73. },
  74. {
  75. test: /\.vue$/,
  76. loader: 'vue-loader',
  77. exclude: BabelLoaderExcludeNodeModulesExcept([
  78. 'vue-material-design-icons',
  79. ]),
  80. },
  81. {
  82. test: /\.js$/,
  83. loader: 'babel-loader',
  84. // automatically detect necessary packages to
  85. // transpile in the node_modules folder
  86. exclude: BabelLoaderExcludeNodeModulesExcept([
  87. '@nextcloud/dialogs',
  88. '@nextcloud/event-bus',
  89. '@nextcloud/vue-dashboard',
  90. 'davclient.js',
  91. 'nextcloud-vue-collections',
  92. 'p-finally',
  93. 'p-limit',
  94. 'p-locate',
  95. 'p-queue',
  96. 'p-timeout',
  97. 'p-try',
  98. 'semver',
  99. 'striptags',
  100. 'toastify-js',
  101. 'v-tooltip',
  102. ]),
  103. },
  104. {
  105. test: /\.(png|jpg|gif)$/,
  106. loader: 'url-loader',
  107. options: {
  108. name: '[name].[ext]?[hash]',
  109. limit: 8192,
  110. },
  111. },
  112. {
  113. test: /\.handlebars/,
  114. loader: 'handlebars-loader',
  115. query: {
  116. extensions: '.handlebars',
  117. },
  118. },
  119. ],
  120. },
  121. plugins: [new VueLoaderPlugin()],
  122. resolve: {
  123. alias: {
  124. OC: path.resolve(__dirname, './core/src/OC'),
  125. OCA: path.resolve(__dirname, './core/src/OCA'),
  126. // make sure to use the handlebar runtime when importing
  127. handlebars: 'handlebars/runtime',
  128. },
  129. extensions: ['*', '.js', '.vue'],
  130. symlinks: false,
  131. },
  132. }, config))