1
0

webpack.common.js 3.0 KB

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