webpack.base.conf.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 env = process.env.NODE_ENV
  7. // check env & config/index.js to decide weither to enable CSS Sourcemaps for the
  8. // various preprocessor loaders added to vue-loader at the end of this file
  9. var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
  10. var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
  11. var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
  12. var now = Date.now()
  13. module.exports = {
  14. entry: {
  15. app: './src/main.js'
  16. },
  17. output: {
  18. path: config.build.assetsRoot,
  19. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
  20. filename: '[name].js'
  21. },
  22. optimization: {
  23. splitChunks: {
  24. chunks: 'all'
  25. }
  26. },
  27. resolve: {
  28. extensions: ['.js', '.vue'],
  29. modules: [
  30. path.join(__dirname, '../node_modules')
  31. ],
  32. alias: {
  33. 'vue$': 'vue/dist/vue.runtime.common',
  34. 'static': path.resolve(__dirname, '../static'),
  35. 'src': path.resolve(__dirname, '../src'),
  36. 'assets': path.resolve(__dirname, '../src/assets'),
  37. 'components': path.resolve(__dirname, '../src/components')
  38. }
  39. },
  40. module: {
  41. noParse: /node_modules\/localforage\/dist\/localforage.js/,
  42. rules: [
  43. {
  44. enforce: 'pre',
  45. test: /\.(js|vue)$/,
  46. include: projectRoot,
  47. exclude: /node_modules/,
  48. use: {
  49. loader: 'eslint-loader',
  50. options: {
  51. formatter: require('eslint-friendly-formatter'),
  52. sourceMap: config.build.productionSourceMap,
  53. extract: true
  54. }
  55. }
  56. },
  57. {
  58. test: /\.vue$/,
  59. use: 'vue-loader'
  60. },
  61. {
  62. test: /\.jsx?$/,
  63. include: projectRoot,
  64. exclude: /node_modules\/(?!tributejs)/,
  65. use: 'babel-loader'
  66. },
  67. {
  68. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  69. use: {
  70. loader: 'url-loader',
  71. options: {
  72. limit: 10000,
  73. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  74. }
  75. }
  76. },
  77. {
  78. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  79. use: {
  80. loader: 'url-loader',
  81. options: {
  82. limit: 10000,
  83. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  84. }
  85. }
  86. },
  87. ]
  88. },
  89. plugins: [
  90. new ServiceWorkerWebpackPlugin({
  91. entry: path.join(__dirname, '..', 'src/sw.js'),
  92. filename: 'sw-pleroma.js'
  93. })
  94. ]
  95. }