webpack.base.conf.js 3.3 KB

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