webpack.base.conf.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. var path = require('path')
  2. var config = require('../config')
  3. var utils = require('./utils')
  4. var projectRoot = path.resolve(__dirname, '../')
  5. var ServiceWorkerWebpackPlugin = require('serviceworker-webpack5-plugin')
  6. var CopyPlugin = require('copy-webpack-plugin');
  7. var { VueLoaderPlugin } = require('vue-loader')
  8. var ESLintPlugin = require('eslint-webpack-plugin');
  9. var env = process.env.NODE_ENV
  10. // check env & config/index.js to decide weither to enable CSS Sourcemaps for the
  11. // various preprocessor loaders added to vue-loader at the end of this file
  12. var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
  13. var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
  14. var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
  15. var now = Date.now()
  16. module.exports = {
  17. entry: {
  18. app: './src/main.js'
  19. },
  20. output: {
  21. path: config.build.assetsRoot,
  22. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
  23. filename: '[name].js',
  24. chunkFilename: '[name].js'
  25. },
  26. optimization: {
  27. splitChunks: {
  28. chunks: 'all'
  29. }
  30. },
  31. resolve: {
  32. extensions: ['.mjs', '.js', '.jsx', '.vue'],
  33. modules: [
  34. path.join(__dirname, '../node_modules')
  35. ],
  36. alias: {
  37. 'static': path.resolve(__dirname, '../static'),
  38. 'src': path.resolve(__dirname, '../src'),
  39. 'assets': path.resolve(__dirname, '../src/assets'),
  40. 'components': path.resolve(__dirname, '../src/components'),
  41. 'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
  42. },
  43. fallback: {
  44. 'querystring': require.resolve('querystring-es3'),
  45. 'url': require.resolve('url/')
  46. }
  47. },
  48. module: {
  49. noParse: /node_modules\/localforage\/dist\/localforage.js/,
  50. rules: [
  51. {
  52. enforce: 'post',
  53. test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
  54. type: 'javascript/auto',
  55. loader: '@intlify/vue-i18n-loader',
  56. include: [ // Use `Rule.include` to specify the files of locale messages to be pre-compiled
  57. path.resolve(__dirname, '../src/i18n')
  58. ]
  59. },
  60. {
  61. test: /\.vue$/,
  62. loader: 'vue-loader',
  63. options: {
  64. compilerOptions: {
  65. isCustomElement(tag) {
  66. if (tag === 'pinch-zoom') {
  67. return true
  68. }
  69. return false
  70. }
  71. }
  72. }
  73. },
  74. {
  75. test: /\.jsx?$/,
  76. include: projectRoot,
  77. exclude: /node_modules\/(?!tributejs)/,
  78. use: 'babel-loader'
  79. },
  80. {
  81. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  82. type: 'asset',
  83. generator: {
  84. filename: utils.assetsPath('img/[name].[hash:7][ext]')
  85. }
  86. },
  87. {
  88. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  89. type: 'asset',
  90. generator: {
  91. filename: utils.assetsPath('fonts/[name].[hash:7][ext]')
  92. }
  93. },
  94. {
  95. test: /\.mjs$/,
  96. include: /node_modules/,
  97. type: 'javascript/auto'
  98. }
  99. ]
  100. },
  101. plugins: [
  102. new ServiceWorkerWebpackPlugin({
  103. entry: path.join(__dirname, '..', 'src/sw.js'),
  104. filename: 'sw-pleroma.js'
  105. }),
  106. new ESLintPlugin({
  107. extensions: ['js', 'vue'],
  108. formatter: require('eslint-formatter-friendly')
  109. }),
  110. new VueLoaderPlugin(),
  111. // This copies Ruffle's WASM to a directory so that JS side can access it
  112. new CopyPlugin({
  113. patterns: [
  114. {
  115. from: "node_modules/@ruffle-rs/ruffle/**/*",
  116. to: "static/ruffle/[name][ext]"
  117. },
  118. ],
  119. options: {
  120. concurrency: 100,
  121. },
  122. })
  123. ]
  124. }