webpack.base.conf.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. resolve: {
  22. extensions: ['', '.js', '.vue'],
  23. fallback: [path.join(__dirname, '../node_modules')],
  24. alias: {
  25. 'vue$': 'vue/dist/vue.runtime.common',
  26. 'src': path.resolve(__dirname, '../src'),
  27. 'assets': path.resolve(__dirname, '../src/assets'),
  28. 'components': path.resolve(__dirname, '../src/components')
  29. }
  30. },
  31. resolveLoader: {
  32. fallback: [path.join(__dirname, '../node_modules')]
  33. },
  34. module: {
  35. noParse: /node_modules\/localforage\/dist\/localforage.js/,
  36. preLoaders: [
  37. {
  38. test: /\.vue$/,
  39. loader: 'eslint',
  40. include: projectRoot,
  41. exclude: /node_modules/
  42. },
  43. {
  44. test: /\.js$/,
  45. loader: 'eslint',
  46. include: projectRoot,
  47. exclude: /node_modules/
  48. }
  49. ],
  50. loaders: [
  51. {
  52. test: /\.vue$/,
  53. loader: 'vue'
  54. },
  55. {
  56. test: /\.jsx?$/,
  57. loader: 'babel',
  58. include: projectRoot,
  59. exclude: /node_modules\/(?!tributejs)/
  60. },
  61. {
  62. test: /\.json$/,
  63. loader: 'json'
  64. },
  65. {
  66. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  67. loader: 'url',
  68. query: {
  69. limit: 10000,
  70. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  71. }
  72. },
  73. {
  74. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  75. loader: 'url',
  76. query: {
  77. limit: 10000,
  78. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  79. }
  80. }
  81. ]
  82. },
  83. eslint: {
  84. formatter: require('eslint-friendly-formatter')
  85. },
  86. vue: {
  87. loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
  88. postcss: [
  89. require('autoprefixer')({
  90. browsers: ['last 2 versions']
  91. })
  92. ]
  93. },
  94. plugins: [
  95. new ServiceWorkerWebpackPlugin({
  96. entry: path.join(__dirname, '..', 'src/sw.js'),
  97. filename: 'sw-pleroma.js'
  98. })
  99. ]
  100. }