webpack.base.conf.js 2.6 KB

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