webpack.common.js 3.5 KB

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