webpack.base.conf.js 3.0 KB

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