webpack.base.conf.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 FontelloPlugin = require("fontello-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. },
  18. output: {
  19. path: config.build.assetsRoot,
  20. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
  21. filename: '[name].js'
  22. },
  23. optimization: {
  24. splitChunks: {
  25. chunks: 'all'
  26. }
  27. },
  28. resolve: {
  29. extensions: ['.js', '.vue'],
  30. modules: [
  31. path.join(__dirname, '../node_modules')
  32. ],
  33. alias: {
  34. 'vue$': 'vue/dist/vue.runtime.common',
  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. new FontelloPlugin({
  95. config: require('../static/fontello.json'),
  96. name: 'fontello',
  97. output: {
  98. css: 'static/[name].' + now + '.css', // [hash] is not supported. Use the current timestamp instead for versioning.
  99. font: 'static/font/[name].' + now + '.[ext]'
  100. }
  101. })
  102. ]
  103. }