webpack.common.js 3.6 KB

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